Delphi7 API (5) Message article: Wm_lbuttondown, Lbuttonup, Lbuttonmove

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.