|
|
Title | Make a window stay below all others in Visual Basic 6 |
Description | This example shows how to make a window stay below all others in Visual Basic 6. |
Keywords | bottommost, topmost, subclass, windowproc, setwindowlong, on bottom, Visual Basic 6, VB 6 |
Categories | API, Tips and Tricks |
|
|
When it starts, the program subclasses its form. The following code shows the new WindowProc.
When it sees a WM_ACTIVATE or WM_PAINT message, it uses the SetWindowPos API function to move the form to the bottom of the stacking order.
|
|
' Handle messages.
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg _
As Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
Const WM_ACTIVATE = &H6
Const WM_PAINT = &HF
Const WM_NCDESTROY = &H82
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const HWND_BOTTOM = 1
Dim lFlags As Long
If (msg = WM_ACTIVATE) Or (msg = WM_PAINT) Then
' We're being activated. Move to bottom.
lFlags = SWP_NOSIZE Or SWP_NOMOVE
SetWindowPos hwnd, HWND_BOTTOM, _
0, 0, 0, 0, lFlags
ElseIf msg = WM_NCDESTROY Then
' We're being destroyed.
' Restore the original WindowProc.
SetWindowLong _
hwnd, GWL_WNDPROC, _
OldWindowProc
End If
NewWindowProc = CallWindowProc( _
OldWindowProc, hwnd, msg, wParam, _
lParam)
End Function
|
|
|
|
|
|