Windows Programming [5]-process 5 of learning form generation

Source: Internet
Author: User
Based on the previous introduction, you can create a window:
Program project1; uses Windows, messages; {window callback function, which must be declared Program Front} function wndproc (WND: hwnd; MSG: uint; wparam: integer; lparam: integer): integer; stdcall; begin result: = 0; if MSG = wm_destroy then {when the window is destroyed} postquitmessage (0) {tell getmessage: Exit !} Else result: = defwindowproc (WND, MSG, wparam, lparam); {other messages are processed by default} end; {main program} var hwnd: thandle; MSG: tmsg; mywndclass: twndclass; begin {specify window type} mywndclass. style: = cs_hredraw or cs_vredraw; {re-paint after changing the size} mywndclass. lpfnwndproc: = @ wndproc; {callback function pointer} mywndclass. cbclsextra: = 0; {No additional window class information} mywndclass. cbwndextra: = 0; {No additional window information} mywndclass. hinstance: = hinstance; {program instance handle} mywndclass. hicon: = 0; {No icon specified} mywndclass. hcursor: = loadcursor (0, idc_arrow); {the pointer provided by the system is selected} mywndclass. hbrbackground: = hbrush (color_window + 1); {the background color uses the Windows Default window color} mywndclass. lpszmenuname: = nil; {default menu not specified} mywndclass. lpszclassname: = 'mywindowclass'; {name the window type} {register the window type} registerclass (mywndclass); {create a window and return a handle} hwnd: = createwindow ('mywindowclass ', {window type name} 'new Window', {Title} ws_overlappedwindow, {General window style} INTEGER (cw_usedefault), {default horizontal position} INTEGER (cw_usedefault ), {default vertical position} INTEGER (cw_usedefault), {default width} INTEGER (cw_usedefault), {default height} 0, {No parent window} 0, {No Main Menu} hinstance, {instance handle} nil {no additional information}); {display window} showwindow (hwnd, sw_shownormal); // updatewindow (hwnd ); {do you want to update the window?} {message loop} while (getmessage (MSG, 0, 0, 0) do begin translatemessage (MSG ); {reprocessing of some keyboard messages} dispatchmessage (MSG); {send the message to the callback function} end; end.
 
   
 

Then we will continue to improve theseCode!

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.