Examples such as the following
ProgramProject1;usesWindows, Messages;{Custom procedure for WM_LBUTTONDOWN message invocation}procedureOnLButtonDown (h:hwnd);varBrushhandle:hbrush; Rect:trect;beginGetClientRect (H, Rect); {Get client Area rectangle}Brushhandle:= CreateSolidBrush (RGB (0,0,0));{Build a black brush}FillRect (GetDC (h), Rect, Brushhandle); {Populate Customer Area}DeleteObject (Brushhandle); {Remove Brush}End;{Custom procedure for WM_LBUTTONUP message invocation}procedureOnLButtonUp (h:hwnd);varRect:trect;beginGetClientRect (H, Rect); {Get client Area rectangle}invalidaterect (H, @Rect, True);{invalidates the client area, forcing redrawing}End;{Custom procedure for WM_MOUSEMOVE message invocation}procedureOnMouseMove (H:hwnd; lparam:integer);varPt:tpoint; BUF:Array[0..255] ofChar;beginPt. X:= LoWord (LParam);{the lower two bits in the LParam are x-coordinates}Pt. Y:= HiWord (LParam);{the high two-bit in the LParam is the y-coordinate}wvsprintf (buf,'%d,%d', @pt);{format to Buffer}SetWindowText (H, buf); {Show in title}End;functionWndProc (Wnd:hwnd; msg:uint; wparam:integer; lparam:integer): Integer;stdcall;beginResult:=0; CaseMsg ofWm_lbuttondown:onlbuttondown (WND);{left mouse button pressed message}Wm_lbuttonup:onlbuttonup (WND); {the message that the left mouse button lifts up}Wm_mousemove:onmousemove (WND, LParam); {The mouse moves the message, coordinates the position in the LParam}Wm_destroy:postquitmessage (0); ElseResult:=DefWindowProc (WND, MSG, WParam, LParam); End;End;functionRegmywndclass:boolean;varCls:twndclass;beginCls.style:= Cs_hredraworCs_vredraw; Cls.lpfnwndproc:=@WndProc; Cls.cbclsextra:=0; Cls.cbwndextra:=0; Cls.hinstance:=hinstance; Cls.hicon:=0; Cls.hcursor:= LoadCursor (0, Idc_arrow); Cls.hbrbackground:= Hbrush (Color_window +1 ); Cls.lpszmenuname:=Nil; Cls.lpszclassname:='Mywnd'; Result:= RegisterClass (CLS) <>0;End;{Program Entry}ConstTit='New Form'; WS=Ws_overlappedwindow; X= -; y = -; W = -; h = the;varHwnd:thandle; msg:tmsg;beginRegmywndclass; HWnd:= CreateWindow ('Mywnd', tit, WS, X, Y, W, H,0,0, HINSTANCE,Nil); ShowWindow (HWnd, SW_SHOWNORMAL); UpdateWindow (HWND); while(GetMessage (MSG,0,0,0)) Do beginTranslateMessage (MSG); DispatchMessage (MSG); End;End.
Delphi7 API (5) Message article: Wm_lbuttondown, Lbuttonup, Lbuttonmove