how can I force a window in my app to stay on top of all other windows in the same app, sort of like a floating toolbox kinda thing??
Printable View
how can I force a window in my app to stay on top of all other windows in the same app, sort of like a floating toolbox kinda thing??
To Stay On Top On Top put this when your app loads.
Code:SetWindowPos hwndofthewindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_FRAMECHANGED Or SWP_NOMOVE
And of course, to do this, you will need the api function and flags as well.
Code:Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Sorry for not including the API declaration and the constants but i haven't written code in VB for a month.I am using VC++ right now and in VC++ these things don't have to be declared.
If the Constants are small numbers like 1, 2, -1 etc. I usually do not bother including them.
Why not? What if you don't remeber what the constants actually mean?
Actually i usally skip the constant declarations myself, but that doesn't mean small flags and large flags differ, flags are flags.