Declare PtrSafe Function
CallWindowProcA Lib "user32" (ByVal lpPrevWndFunc As LongPtr, ByVal hwnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
Declare PtrSafe Function
SetWindowLongPtrA Lib "user32" (ByVal hwnd As LongPtr, ByVal nIndex As Long,ByVal dwNewLong As LongPtr) As Long
(Public Const GWL_WNDPROC = (-4
Global oldwndproc As LongPtr
Global wndHW As LongPtr
: Form_Load
wndHw=Me.Hwnd
(oldwndproc = SetWindowLongPtrA(Me.hwnd, GWL_WNDPROC, AddressOf WndProc
: Form_Unload
SetWindowLongPtrA wndHw, GWL_WNDPROC, oldwndproc
Public Function WndProc(ByVal lhwnd As LongPtr, ByVal uMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As Long
If uMsg = 516 Then 'WM_RBUTTONDOWNU
'Debug.Print "Intercepted WM_CONTEXTMENU at " & Now
" MsgBox "Mouse Right Button Was Clicked
WndProc=-1
ElseIf uMsg = WM_KEYDOWN Then
MsgBox wParam
WndProc = True
Else ' Send all other messages to the default message handler
(WndProc = CallWindowProcA(oldwndproc, lhwnd, uMsg, wParam, lParam
End If
End Function
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const VK_UP = &H26
Public Const VK_DOWN = &H28
Public Const VK_HOME = &H24
Public Const VK_LEFT = &H25
Public Const VK_PRIOR = &H21
Public Const VK_LBUTTON = &H1 ' Left mouse button
Public Const VK_RBUTTON = &H2 ' Right mouse button
Public Const VK_MBUTTON = &H4 ' Middle mouse button (three-button mouse)
Public Const SC_SIZE = &HF000&
Public Const SC_MOVE = &HF010&
Public Const SC_MINIMIZE = &HF020&
Public Const SC_MAXIMIZE = &HF030&
Public Const SC_NEXTWINDOW = &HF040&
Public Const SC_PREVWINDOW = &HF050&
Public Const SC_CLOSE = &HF060&
Const WM_NCLBUTTONDOWN As Integer = 161
Const WM_SYSCOMMAND As Integer = 274
Const HTCAPTION As Integer = 2
Const SC_MOVE As Integer = 61456
If (Msg = WM_SYSCOMMAND) And (WParam = SC_MOVE) Then
Return
End If
If (Msg = WM_NCLBUTTONDOWN) And (WParam = HTCAPTION) Then
Return
If (Msg = WM_RBUTTONDOWN) And (WParam = WM_RBUTTONDOWN) Then
Return
End If
وقتی دابل کلیک روی قسمت تایتل بار انجام میشود یا بعبارتی قسمت کپشن پنجره عمل ماکسیمایز پنجره انجام خواهد گرفت
If umsg = WM_NCLBUTTONDBLCLK And wParam = 2 Then Exit Function
SYsMenu عمل نکردن منوهای تایتل بار یا
If umsg = WM_SYSCOMMAND And ((wParam = SC_CLOSE) Or (wParam = SC_MINIMIZE) Or (wParam = SC_MAXIMIZE)) Then
Exit Function
مثال دیگر :
If Msg = WM_NCDESTROY Then
SetWindowLong hWnd,GWL_WNDPROC,OldWindowProc
If Msg <> WM_CONTEXTMENU Then
NoPopupWindowProc = CallWindowProc(OldWindowProc,hWnd
,Msg,wParam,lParam)
----------------------------------------
اگر از HOOK استفاده شود و آیدی WH_MOUSE یا WH_MOUSE_LL
If Wparam=WM_NCLBUTTONDBLCLK Then
MouseHookProc=NoneZero
End If
(20×16)×1.6+4=516 ( DECIMAL )
516÷16=32
516-(32×16)=4
(516÷16)×10=320
320÷16=20
List Of Windows Message SendMessageList