Jump to content
Tuts 4 You

keep the window on top


Bleed

Recommended Posts

Posted

Hi,

I'm coding on some win32 c++ app. What API should I use to keep the window on top of other windows regardless if it is selected or not?

I'm just guessing it is an API, but I'm not sure if it is one. :confused:

TheCodeCracker
Posted

You should set the windows extended style to WS_EX_TOPMOST

Posted

Hi here is a masm example

invoke IsDlgButtonChecked,hWnd,IDC_ALWAYSONTOP

.if eax==BST_CHECKED

mov eax,HWND_TOPMOST

.else

mov eax,HWND_NOTOPMOST

.endif

invoke SetWindowPos,hWnd,eax,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE

I think this is not difficult to translate in c++

greets,

Posted

Thanks!

So very helpful!

:thumbsup:

Posted

Use SetWindowLong (Ptr if you want it to support x64) or just SetWindowPos()

get the Window handle (hWnd) and use SetWindowPos on it, with IDC_ALWAYSONTOP or WS_EX_TOPMOST :) .

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...