1. win32 Window Function creation (internal operating mechanism of windows program) and win32 window
To create window functions using win32, follow these steps:
1. Design a window class 2. Register window class 3. Create Window 4. Display and window Update 5. Message loop 6. Window Process function (1) design a window class design window class. This type has been defined by windows, and we only need to fill the defined struct (WNDCLASS) Like the multiple choice question. First, there are two options that are generally set to 0: cbClsExtra and cbWndExtra. These two options are class additional memory and window additional memory. HbrBackground specifies the background paint brush handle of the window class. It can be used to specify a paint brush handle or a standard system color value. HCursor specifies the cursor handle of the window class hIcon specifies the icon handle of the window class hInstance specifies the instance handle of the program containing the Window Process Program lpfnWndProc is a function pointer, point to the window procedure function lpszClassName specify the name of the window class lpszMenuName specify the name of the menu resource style specify the style of the window (2) register the window class RegisterClass (xxx) the parameters in the window are pointers to Windows WNDCLASS to let the operating system know information about windows of this type (3) create windows hwnd = CreateWindow (lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParant, hMenu, hInstance, lpParam) lpClassName specifies the name of the window class, that is, the lpszClassNamelpWindowName in the window class specifies the window style created by dwStyle, mainly What are the coordinates of x, y, nWidth, and nHeight in the upper left corner of the window, long and wide hWndParant: Specify the parent window handle of the window being created. hMenu: Specifies the handle of the window menu. hInstance: Specifies the handle of the application instance to which the window belongs. lpParam is set to NULL in most Windows (4) display and update ShowWindow (hwnd, window display status); UpdateWindow (hwnd); (5) a message loop is required after the message loop is created, displayed, and updated, continuously reads messages from the message queue. GetMessage (lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax) lpMsg points to a message struct (MSG) hWnd, which specifies the message receiving window, which is usually set to NULL, to receive window messages wMsgFilterMin in all windows of the call thread, wMsgFilterMax specifies the minimum and maximum values of the messages to be obtained. It is usually set to the 0GetMessage function for WM_QUIT messages, return 0TranslateMessage and DispatchMessage for further processing of received messages (6) the window procedure function is used to process messages sent to the window. This chapter describes the windows program design through a win32 programming example, it is an interactive, event-driven program design mode based on messages. For more information, see VC ++.