Title | Tell when the user clicks on a form's border, or on the minimize, maximize, or close button |
Keywords | click, border, minimize, maximize, close, non-client area |
Categories | API |
|
' Display messages for non-client border and
' button events.
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg _
As Long, ByVal wParam As Long, ByVal lParam As Long) As _
Long
Static num As Long
Const WM_NCLBUTTONDOWN = &HA1
Const HTBORDER = 18
Const HTBOTTOM = 15
Const HTBOTTOMLEFT = 16
Const HTBOTTOMRIGHT = 17
Const HTCAPTION = 2
Const HTCLOSE = 20
Const HTGROWBOX = 4
Const HTLEFT = 10
Const HTMAXBUTTON = 9
Const HTMINBUTTON = 8
Const HTRIGHT = 11
Const HTSYSMENU = 3
Const HTTOP = 12
Const HTTOPLEFT = 13
Const HTTOPRIGHT = 14
If msg = WM_NCLBUTTONDOWN Then
Select Case wParam
Case HTBORDER
Debug.Print Format$(num, "@@@@") & ": " & _
"(Non-sizable border)"
Case HTBOTTOM
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, bottom)"
Case HTBOTTOMLEFT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, bottom left)"
Case HTBOTTOMRIGHT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, bottom right)"
Case HTGROWBOX
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, grow box)"
Case HTLEFT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, left)"
Case HTRIGHT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, right)"
Case HTTOP
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, Top)"
Case HTTOPLEFT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, Top left)"
Case HTTOPRIGHT
Debug.Print Format$(num, "@@@@") & ": " & _
"(Border, Top right)"
Case HTCAPTION
Debug.Print Format$(num, "@@@@") & ": " & _
"(Caption)"
Case HTCLOSE
Debug.Print Format$(num, "@@@@") & ": " & _
"(Close)"
Case HTMAXBUTTON
Debug.Print Format$(num, "@@@@") & ": " & _
"(Maximize)"
Case HTMINBUTTON
Debug.Print Format$(num, "@@@@") & ": " & _
"(Minimize)"
Case HTSYSMENU
Debug.Print Format$(num, "@@@@") & ": " & _
"(System menu)"
End Select
End If
num = num + 1
' Call the original WindowProc.
NewWindowProc = CallWindowProc( _
OldWindowProc, hwnd, msg, wParam, _
lParam)
End Function
|