MFC first section-windows program internal operation mechanism

Source: Internet
Author: User

First, the window

When designing a window class:

1typedefstruct_wndclass{2UINT style;//If horizontal, vertical changes are redrawn, disable close, detect double-click3WNDPROC Lpfnwndproc;//window procedure function handle4 intCbclsextra;//class Additional Memory5 intCbwndextra;//window attached memory6HANDLE hinstance;//instance handle7HANDLE Hicon;//icons8Hcursor Hcursor;//cursor9Hbrush Hbrbackground;//BrushesTenLPCTSTR Lpszmenuname;//Menu Name OneLPCTSTR lpszClassName;//Name of the window class A}wndclass

The process by which a window function is called:

1. Assign the function address to the lpfnwndproc of the window port

2. Register the window class, the system gets the address of the window procedure function that is written

3. The application obtains the message, passes the message through DispatchMessage (&MSG), invokes the window procedure function processing.

Second, WinMain

WinMain is the portal for Windows programs, including creating window classes for message loops.

1 int WINAPI WinMain (2 hinstance hinstance,// current running instance handle 3 hinstance hPrevInstance,// default NULL4 LPSTR lpcmdline,/ / command line parameter 5 int ncmdshow// window display style 6 );

An application can run multiple instances, each running an instance, and the system will be given a handle and passed to WinMain.

Third, the message

struct Tagmsg{hwnd HWND; // owning Window UINT message; // Message Flags WPARAM WPARAM; // Additional Information LPARAM lparam;dword time; // time to enter message queue Point pt; // mouse current Position } MSG;

Four, DC

DC Device Description table. When programming, either display or print, operate on the DC and map to the appropriate device.

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.