The operating system provides the functions it can accomplish to the application in the form of functions.ProgramApplication calls to these functions are called system calls. The collection of these functions is the Application Programming Interface (Windows API) provided by the Windows operating system for application programming.
The operating system packs each event into a message struct MSG to pass to the application,
The MSG structure is defined as follows:
Typedef struct tagmsg {
Hwnd;
Uint message;
Wparam;
Lparam;
DWORD time;
Point pt;
} MSG;
Handle
Handle, the resource ID.
The operating system needs to manage and operate these resources by using handles to find the corresponding resources. By resource type, you can also subdivided the handle into the icon handle (hicon), the cursor handle (hcursor), the window handle (hwnd), and the application instance handle (hinstance) and other types of handles. The operating system specifies a unique identification number for each window, that is, the window handle.
Winmain Function
Entry functions of Windows programs
Int winapi winmain (
Hinstance, // handle to current instance
Hinstance hprevinstance, // handle to previous instance
Lpstr lpcmdline, // command line
Int ncmdshow // show state
);
Window Creation
To create a complete window, follow these four steps:
Design a window class;
Registration window class;
Create window;
Display and update window.
Typedef struct _ wndclass {
Uint style;
Wndproc lpfnwndproc;
Int cbclsextra;
Int cbwndextra;
Handle hinstance;
Hicon;
Hcursor;
Hbrush hbrbackground;
Lpctstr lpszmenuname;
Lpctstr lpszclassname;
} Wndclass;