always on top window

BlitzMax Forums/BlitzMax Programming/always on top window

gellyware(Posted 2006) [#1]
How do you make a second (or first) window that always stays on top until closed???


Dreamora(Posted 2006) [#2]
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.


gellyware(Posted 2006) [#3]
What if the user clicks "beyond" the second (top) window.... won't the top (second) window close?


Bremer(Posted 2006) [#4]
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)



gellyware(Posted 2006) [#5]
zawran, that is perfect :D thank you