简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

C#SetWindowPos窗口置顶

来源:易贤网   阅读:5319 次  日期:2014-08-29 11:00:38

温馨提示:易贤网小编为您整理了“C#SetWindowPos窗口置顶”,方便广大网友查阅!

[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);

更多信息请查看IT技术专栏

更多信息请查看网络编程
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:.net中使用DatagridView的增删改方法
下一篇:解决ScrollViewer滚动问题的办法
易贤网手机网站地址:C#SetWindowPos窗口置顶
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!