always on top window

BlitzMax Forums/BlitzMax Programming/always on top window

How do you make a second (or first) window that always stays on top until closed???

You can disable the "old" window while the new is active and re-enable it afterwards. This way you get a "modal" window the user has to accept before the original one works again.

What if the user clicks "beyond" the second (top) window.... won't the top (second) window close?

The following should work for making windows always on top and back again.

Extern "win32"
	Function GetActiveWindow()
	Function SetWindowPos(hWnd:Int,after:Int,x:Int,y:Int,w:Int,h:Int,flags:Int)
End Extern

Const SWP_NOSIZE:Int = $1
Const SWP_NOMOVE:Int = $2
Const HWND_TOPMOST:Int = -1
Const HWND_NOTOPMOST:Int = - 2

Function alwaysOnTop(hwnd:Int)
	SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE )
End Function
Function notAlwaysOnTop(hwnd:Int)
	SetWindowPos( hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE )
End Function

' // this is how its used
Local hWnd:Int = GetActiveWindow()
alwaysOnTop(hWnd)


zawran, that is perfect :D thank you