手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >C# SetWindowPos窗口置顶使用说明
C# SetWindowPos窗口置顶使用说明
摘要:复制代码代码如下:[DllImport("user32.dll",CharSet=CharSet.Auto)]privatestaticex...

复制代码 代码如下:

[DllImport("user32.dll", CharSet = CharSet.Auto)]

private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);

/// <summary>

/// 得到当前活动的窗口

/// </summary>

/// <returns></returns>

[DllImport("user32.dll", CharSet = CharSet.Auto)]

private static extern System.IntPtr GetForegroundWindow();

哪个窗体想要置顶,在Form_Load中加上

SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); //最后参数也有用1 | 4

具体说明,看API函数说明

如果是用点击一个按钮后弹出新窗体,并置顶,则:

复制代码 代码如下:

Form2 frm = new Form2();

frm.Show();

SetWindowPos(GetForegroundWindow(), -1, 0, 0, 0, 0, 1 | 2);

这样,新打开的窗体就是置顶了

【C# SetWindowPos窗口置顶使用说明】相关文章:

asp.net为网页动态添加关键词的方法

asp.net下PageMethods使用技巧

用sender的Parent获取GridView中的当前行

无法在Web服务器上启动调试。未将项目配置为进行调试

C# javaScript函数的相互调用

ajaxControlToolkit中CascadingDropDown的用法说明

DropDownList绑定数据表实现两级联动示例

C# ToString格式大全

ASP.NET Session使用详解

asp.net 因为数据库正在使用的解决方法

精品推荐
分类导航