VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

AppOnTop

VB FAQ  (6 Submissions)   Custom Controls/Forms/Menus   Visual Basic 3.0   Unknown Difficulty   Wed 3rd February 2021

How do I get my application on top?To make your window truly topmost, use the SetWindowPos API call

Assumes
You can, to make the application stay on top, put the ZOrder method in a Timer event repeatedly called, say, every 1000 milliseconds. This makes a "softer" on-top than other methods, and allows the user to make a short peek below the form. There are two different Zorder's of windows (forms) in Windows, both implemented internally as linked lists. One is for "normal" windows, the other for "topmost" windows (like the Clock application which is distributed with Windows). The ZOrder command above simply moves your window to the top of the "normal" window stack. There is another, independent stack for topmost windows - like those created by the example code above - which resolves problems if several of those should conflict. Note that when a form is minimized, it loses its topmost attribute and you will have to set it again.

API Declarations


#IF WIN32 THEN
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
#ELSE 'Win16
Declare Sub SetWindowPos Lib "User" (ByVal hWnd As Integer, _
ByVal hWndInsertAfter As Integer, ByVal X As Integer, _
ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, _
ByVal wFlags As Integer)
#END IF
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

Rate AppOnTop (7(7 Vote))
AppOnTop.bas

AppOnTop Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters