如何在.NET中控制Windows应用程序焦点
我使用 pinvoke“user32.dll”将我的应用程序发送到后面(所有其他应用程序后面),以便它位于桌面上,反之亦然。目前它只是切换 - 后/前。有没有办法检测我的应用程序是否在后面并将其带到前面,或者如果它在前面并将其发送到后面?谢谢。
I'm using pinvoke "user32.dll" to send my application to back (behind all other apps) so it sits on desktop and vice versa. At the moment it just toggles - back/front. Is there a way to detect if my app is at the back and bring it to front or if it's on front and send it to back? THanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过调用来检测您的窗口是否是活动窗口。
您曾经可以调用
将您的窗口设置为前台,但 Microsoft 在 Windows ME/2000 及以后版本中更改了它的功能(可能是 XP?)。
针对此问题有多种解决方法,您可能需要测试一些,看看哪种方法适合您。
http://www.tek-tips.com/faqs.cfm?fid= 4262章
第
我记得读过有关可以设置为允许 SetForegroundWindow 根据需要工作的注册表项的信息,但它是系统范围的设置。
http://www.delphipages.com/forum/showthread.php?t= 198261
如果有帮助,您可以使用 SetWindowPos 将窗口放置在其他窗口后面或永久放在顶部
http://www.pinvoke.net/default.aspx/user32.SetWindowPos
http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx
You can detect if your window is the active window by calling
You used to be able to call
to set your window to the foreground, but Microsoft changed it's functionality in Windows ME/2000 onwards (May have been XP?).
There are various work arounds attempts for this issue, you may need to test a few to see which works for you.
http://www.tek-tips.com/faqs.cfm?fid=4262
http://markribau.org/blog/?p=7
I remember reading about a registry entry that can be set to allow SetForegroundWindow to work as desired, but it's a system wide setting.
http://www.delphipages.com/forum/showthread.php?t=198261
You can use SetWindowPos to place you window behind other windows or permanently on top if that helps
http://www.pinvoke.net/default.aspx/user32.SetWindowPos
http://msdn.microsoft.com/en-us/library/ms633545(VS.85).aspx