Click here to Skip to main content
14,360,900 members
Rate this:
Please Sign up or sign in to vote.
See more:
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.
Updated 1-Feb-12 13:37pm
Steve Wellens 1-Feb-12 18:03pm
Why would you want to do something so annoying to the user?
BillWoodruff 1-Feb-12 19:10pm
What is the nature of the full-screen application which you wish to bring a WinForm in front of ? Is it an application you have written ?

Is it a .NET application ? WinForms, WPF ? ... a XNA or DirectX game written in C++ ? ... or ? Do you even know ?

If that full-screen application is full-screened because it's using XNA or DirectX, as many games are: I am not sure this can be done.
@nubiz93 2-Feb-12 11:00am
The applications are made in Flash and Unity. No, I did not create the applications.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100