Delphi7 API (4) Message _ Create

Source: Internet
Author: User

Message creation Wm_create:

The code is as follows

Program project1;uses Windows, Messages; {Custom procedure}procedure OnPaint (H:hwnd) for WM_PAINT message invocation;ConstStr='Windows program created by';varDc:hdc;  Ps:paintstruct; Rect:trect;begin MessageBeep (0); DC:=BeginPaint (H, PS);  GetClientRect (H, Rect); DrawText (DC, PChar (str),-1, Rect, dt_singleline or Dt_center or dt_vcenter); EndPaint (H, PS), end;function WndProc (Wnd:hwnd; msg:uint; wparam:integer; lparam:integer): Integer; Stdcall;begin Result:=0;  Casemsg of Wm_paint:onpaint (WND);    {A custom OnPaint procedure is called when a WM_PAINT message is received} Wm_destroy:postquitmessage (0); ElseResult:=DefWindowProc (WND, MSG, WParam, LParam); End;end;function Regmywndclass:boolean;varcls:twndclass;begin Cls.style:=Cs_hredraw or Cs_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;begin Regmywndclass; 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)) Dobegin TranslateMessage (MSG);  DispatchMessage (MSG); End;end.

Delphi7 API (4) Message _ Create

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.