Here under sample program for always on top, although many form be opened. program listing write on top list code source program we made

-----------cut here-----------------------------------

option explicit
const HWND_TOPMOST = -1
const HWND_NOTOPMOST = -2
const SWP_NOMOVE = &H2
const SWP_NOSIZE = &H1
const SWP_NOACTIVE = &H10
const SWP_SHOWWINDOW = &H10
const TOPMOST_FLAGS = SWP_NOMOVE or SWP_NOSIZE

Private declare function SetWindowPos lib _
"user32" (ByVal hwnd as long, ByVal _
hWndInsertAfter as long, ByVal x as long, y, _
ByVal cx as long, ByVal cy as long, ByVal _
wflags as long) as long

Public sub MakeNormal(Handle as long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, _
0,0,TOPMOST_FLAGS
End Sub

Public sub MakeOnTop(Handle as long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, _
0,0,TOPMOST_FLAGS
End Sub

Sample in use

MakeOnTop Form1.hwnd

-------------------Finish-----------------------------

download sample program and source code

0 komentar