码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-10-15 19:42:38      阅读:110      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!