Skip to main content
GameDev.net gamedev.net
🔒 Locked

Bring window into focus

Started by malpass Apr 9, 2004 at 6:34 AM 7 replies 6.8k views
Original Post
malpass
malpass
How do I get my application to be brought to the top of all other windows and activate. I''m using C#, I tryed this.Activate(), but this just makes the bar in the start bar to flash, but it doesnt actually appear in front of the current application
Aprosenf
Aprosenf
I don''t know C#, but in C++, you would call SetFocus(hwndMyWindow); . Maybe there is a similar function such as this.SetFocus in C#?
malpass
malpass
Well I used DllImport and tryed SetFocus, that just gives it input focus and makes the bar flash the same as Activate(), but doesnt bring it forward. I also tryed BringWindowToFront() and SetForegroundWindow(), all with this.Handle, but non work. Is this maybe a problem with this.Handle? yet that returns the hWnd of the form, I have used it in other programs

[edited by - malpass on April 9, 2004 12:14:58 PM]
daerid
daerid
You could try making it a top level window when it is brought forward. But that would disallow any windows to be put on top of it.

The flashing behavior is a fundamental operation of Windows GDI. Dunno if you can bypass it using the straight Win32 API.


daerid | Legends | Garage Games | Spirit | Hapy | Boost | Python | Google
"Doomed to crumble, unless we grow, and strengthen our communication" - Maynard James Keenan, Tool
daerid@gmail.com
Aprosenf
Aprosenf
Again, I don''t know about C#, but in C++ I just found a function that sounds just like what you want: BringWindowToTop. See if that works. If that doesn''t exist, try SetWindowPos and use the HWND_TOP flag for the argument hWndInsertAfter.
iMalc
iMalc
What you are trying to do is explicitly prevented by XP. You may want to look up the AllowSetForegroundWindow function for details. Using ASFW you can allow one of your programs to bring your other app to the front, but I don''t think even this will help in your situation. It cannot be done if the front application wont allow it.
Oluseyi
Oluseyi
Sheesh, I need to pay closer attention.

You need to set the TopMost property to true, and then call Show().

[Edit: Bad HTML!]

[edited by - Oluseyi on April 9, 2004 12:57:06 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.