How
do I get my application on top?
To force a form to the front of the screen, use the following command: Form1.ZOrder
To make the application stay on top, put the Zorder command in a Timer event repeatedly
called, say every 1000 msecs. 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 forms in Windows, both implemented
internally as linked lists. One is for "normal" windows, the other for real
"topmost" windows (like the Clock application which is distributed with MS
Windows). The Zorder command above simply moves your window to the top of the
"normal" window stack. To make your window truly topmost, use the SetWindowPos
API call like this: 'Make these declares: Declare
Function SetWindowPos Lib "user32" _
(ByVal h%, ByVal hb%, ByVal x%, ByVal y%, _
ByVal cx%,ByVal cy%,ByVal f%) As Integer
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
'To set Form1 as a TopMost form, do the following: res%
= SetWindowPos (Form1.hWnd, HWND_TOPMOST, _
0, 0, 0, 0, FLAGS)
'if res%=0, there is an
error
'To turn off topmost (make the form act normal again): res% =
SetWindowPos (Form1.hWnd, HWND_NOTOPMOST, _
0, 0, 0, 0, FLAGS)
|