使用C#将Windows窗体带到Windows前面 [英] Bringing a windows form in front of windows using c#

查看:101
本文介绍了使用C#将Windows窗体带到Windows前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从另一个Windows窗体中声明并初始化一个Windows窗体,然后将其置于另一个应用程序的前面.必须使用 System.Timers来调用将表单置于最前面的函数. Timer.Elapsed [ ^ ]事件处理程序.

我试图使用 SetForegroundWindow [ ^ ] Windows函数可将表单置于最前面,但这会使应用程序无法全屏显示.我需要与表单进行交互,而不会导致应用程序无法全屏显示. BringWindowToTop [

I need to declare and initialize a windows form from within another windows form and then bring it in front of another application. The function to bring the form to the front must be called using a System.Timers.Timer.Elapsed[^] event handler.

I have attempted to use the SetForegroundWindow[^] windows function to bring the form to the front, but that knocks the application out of full screen. I need to interact with the form without knocking the application out of full screen. BringWindowToTop[^] seems to solve this issue, but calling it throws cross-threading errors.

I am using a delegate to call BringWindowToTop and the Timer and BringWindowToTop function is defined/called from the form I wish to bring to the front.

推荐答案

听起来这不是一个好主意,但是如果这是您的要求...

显而易见的解决方案是解决调用BringWindowToTop时的线程问题.
此处查看 [ ^ ].尽管您无需更改控件,但适用相同的原理.
This doesn''t sound like a great idea but if that''s your requirements...

The obvious solution is to solve your threading issues when calling BringWindowToTop.

Have a look here[^]. Although your not changing a control, the same principle applies.


这篇关于使用C#将Windows窗体带到Windows前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆