Windows Programming [1]-process 1 of form generation

Source: Internet
Author: User
In this example:


Create a new console program and paste the following code to run it:

Program project1; uses Windows, messages; {the process of waiting for calling, used to draw text on the form} procedure onpaint (H: HDC); const S = 'codegear Delphi 2007 '; begin textout (H, 10, 10, pchar (s), length (s); end; {window callback process} function wndproc (WND: hwnd; MSG: uint; wparam: integer; lparam: integer): integer; stdcall; var handle: HDC; PS: paintstruct; begin case MSG of wm_paint: Begin handle: = beginpaint (WND, PS ); onpaint (handle); endpaint (WND, PS); Result: = 0; end; wm_destroy: Begin postquitmessage (0); Result: = 0; end; else result: = defwindowproc (WND, MSG, wparam, lparam); end; {main program} var hwnd: thandle; MSG: tmsg; mywndclass: twndclass; begin mywndclass. style: = cs_hredraw or cs_vredraw; mywndclass. lpfnwndproc: = @ wndproc; mywndclass. cbclsextra: = 0; mywndclass. cbwndextra: = 0; mywndclass. hinstance: = hinstance; mywndclass. hicon: = loadicon (0, idi_question); mywndclass. hcursor: = loadcursor (0, idc_arrow); mywndclass. hbrbackground: = hbrush (getstockobject (white_brush); mywndclass. lpszmenuname: = nil; mywndclass. lpszclassname: = 'mywindowclass'; registerclass (mywndclass); hwnd: = createwindow ('mywindowclass', 'This is the window title', ws_overlappedwindow, 100,100,250,150, 0, 0, hinstance, nil ); showwindow (hwnd, sw_shownormal); updatewindow (hwnd); While (getmessage (MSG, 0, 0, 0) do begin translatemessage (MSG); dispatchmessage (MSG); end; end.
 

We plan to start from here to learn more about the underlying things. First, let's understand the code!

Related Article

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.