足球游戏_中国足彩网¥体育资讯$

C#SetWindowPos窗口置顶
来源:易贤网 阅读:5479 次 日期: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技术专栏

中国足彩网信息请查看网络编程
易贤网手机网站地址:C#SetWindowPos窗口置顶
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 新媒体/短视频平台 | 手机站点

版权所有:易贤网