Click to See Complete Forum and Search --> : force window to stay on top
Jimbob
Oct 13th, 2000, 11:22 AM
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??
Vlatko
Oct 13th, 2000, 12:05 PM
To Stay On Top On Top put this when your app loads.
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.
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
Vlatko
Oct 14th, 2000, 04:31 AM
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.
kedaman
Oct 14th, 2000, 09:13 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.