
.wParam: Handle to the active top-level parent window
LOWORD (lParam): Hit test value where the mouse is clicked. If you clicked the work area, the HTCLIENT
.value is passed
HIWORD (lParam): The ID of the mouse message that caused this message. Depending on the return value of this message, mouse messages are either queued
.or discarded
: MA_ACTIVATE
Activates the window and does not discard mouse messages
: MA_ACTIVATEANDEAT
.Activates the window and discards mouse messages
: MA_NOACTIVATE
Does not activate Windows and does not discard mouse messages
: MA_NOACTIVATEANDEAT
It does not activate the window nor discard the mouse message
The following example prints the letter "C" at a specific location on the screen, which can be moved with the left mouse button. As soon as the button is pressed, the position of the character changes, but it does not process mouse messages when it is changed from inactive to active
(WndProc(hWnd,Msg,wParam,lParam
Dim hdc As Long
Dim ps As PAINTSTRUCT
Dim Ret As Long
static x, y
Select Case Msg
case WM_MOUSEACTIVATE
Ret=MA_ACTIVATEANDEAT
case WM_LBUTTONDOWN
(x=LOWORD (lParam
(y=HIWORD (lParam
InvalidateRect hWnd,0,TRUE
Ret=0
case WM_PAINT
(hdc=BeginPaint(hWnd,ps
TextOut hdc,x,y,"C",1
EndPaint hWnd, & ps
Ret=0
case WM_DESTROY
PostQuitMessage 0
Ret=0
((Ret=DefWindowProc(hWnd,Msg,wParam, lParam
Process messages'
Public Function NewWindowProc(ByVal hwnd As Long,ByVal msg As Long,ByVal wParam As Long,ByVal
(lParam As Long
As Long
Const WM_NCDESTROY=&H82
If we're being destroyed'
restore the original WindowProc'
If msg=WM_NCDESTROY Then
SetWindowLong hwnd,GWL_WNDPROC, OldWindowProc
End If
See if a control was clicked'
If msg=WM_MOUSEACTIVATE Then
Form1.MouseClicked
NewWindowProc=CallWindowProc(OldWindowProc,hwnd,msg,wParam,lParam) End Function
()Public Sub MouseClicked
Dim pt As POINTAPI
See where the mouse is'
GetCursorPos pt
Convert into client coordinates'
ScreenToClient hwnd,pt
Draw a big X on the form where the mouse is'
Cls
(Line (pt.X - 50, pt.Y - 50)-(pt.X + 50, pt.Y + 50
(Line (pt.X + 50, pt.Y - 50)-(pt.X - 50, pt.Y + 50
End Sub
Type tagNCCALCSIZE_PARAMS
RECT] rgrc[]'
rgrc0 As RECT
rgrc1 As RECT
rgrc2 As RECT
lppos
End Type
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type