C#调用API 实现窗体总在最上
2009-06-16 17:28
627 查看
class Win32
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
public const int HWND_BOTTOM = 0x1;
public const uint SWP_NOSIZE = 0x1;
public const uint SWP_NOMOVE = 0x2;
public const uint SWP_SHOWWINDOW = 0x40;
}
private void ShoveToBackground()
{
Win32.SetWindowPos((int)this.Handle, -1, this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height, 1);
//Win32.SetWindowPos(
// (int)this.Handle,
// (int),
// 0, 0, 0, 0,
// Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.HWND_BOTTOM);
}
private void Bar_Activated(object sender, EventArgs e)
{
//总在最上
ShoveToBackground();
}
private void Bar_Leave(object sender, EventArgs e)
{
//总在最上
ShoveToBackground();
}
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
public const int HWND_BOTTOM = 0x1;
public const uint SWP_NOSIZE = 0x1;
public const uint SWP_NOMOVE = 0x2;
public const uint SWP_SHOWWINDOW = 0x40;
}
private void ShoveToBackground()
{
Win32.SetWindowPos((int)this.Handle, -1, this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height, 1);
//Win32.SetWindowPos(
// (int)this.Handle,
// (int),
// 0, 0, 0, 0,
// Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.HWND_BOTTOM);
}
private void Bar_Activated(object sender, EventArgs e)
{
//总在最上
ShoveToBackground();
}
private void Bar_Leave(object sender, EventArgs e)
{
//总在最上
ShoveToBackground();
}
相关文章推荐
- C# 调用API,实现注销远程登录本机的用户
- C# 调用API,实现注销远程登录本机的用户
- C# 调用API,实现注销远程登录本机的用户
- C# 调用API,实现注销远程登录本机的用户
- C# API 应用(根据句柄,实现向另一应用程序登录窗体实现登录)
- 利用System.EventHandler来实现两个窗体间的事件调用 (C#)
- C#通过委托和异步调用实现窗体间的通讯
- C#:调用API实现简繁转换
- 【转】【WPF】 WPF 调用API修改窗体风格实现真正的无边框窗体
- C# 委托实现多线程调用窗体
- C#调用API来实现打开webbrowser中的链接
- WPF 调用API修改窗体风格实现真正的无边框窗体
- C#调用API实现程序间相互控制(附源码)
- 使用C#调用系统API实现内存注入的代码
- C#+API实现指定窗体激活
- 实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
- C# 调用API,实现注销远程登录本机的用户
- Win32关于GDI 的API (Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。有时候我们之直接调用Win32 的API,可以很高效的实现想要)
- 在C#中调用系统API使窗体下拥有阴影效果(转)