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