首页 > 其他 > 详细

2016.5.30让窗口处于最顶层的方法,比TopMost灵活

时间:2016-10-15 19:42:24      阅读:207      评论:0      收藏:0      [点我收藏+]

最简单的方法Form. Activate()

 

稍复杂的方法用API,目前没有看出比第一种方法有什么好处(可操作其它窗口,这就是好处2016.7.31)

 [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]

public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体

SetForegroundWindow(frmAltPro.Handle);

 

[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, ExactSpelling = true)]

public static extern IntPtr GetForegroundWindow(); //获得本窗体的句柄

GetForegroundWindow() //获取当前置顶窗体的句柄

2016.5.30让窗口处于最顶层的方法,比TopMost灵活

原文:http://www.cnblogs.com/mol1995/p/5965001.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!