Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I bring a window to the foreground in Vista using C++?

Tags:

c++

window

winapi

I have a piece of code that brings the window under the cursor to the foreground using the SetForegroundWindow API for WinXP. I have been testing it for Vista but the API seems to no longer do the job correctly.

AllowSetForeground did not help, my process is a background process.

What can I use to accomplish this?

like image 758
Stb Avatar asked Oct 20 '25 05:10

Stb


1 Answers

Try the following code and see if it works for you:

SetWindowPos(WndHandle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(WndHandle,HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
like image 137
newgre Avatar answered Oct 21 '25 18:10

newgre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!