Specific steps for Windows window creation

Source: Internet
Author: User

/*
Six steps to implement window creation:
First step: Create the entry function WinMain
Step Two: Register window class
Part III: The function of implementing the callback function
Fourth Step: Display window
Fifth Step: Update window
Sixth step: Message loop
*/

#include "stdafx.h"
callback function
LRESULT CALLBACK WinProc (HWND hwnd,uint umsg,wparam wparam,lparam LPARAM)
{
Switch (umsg)
{
Case WM_CREATE:
{
MessageBox (NULL, "a window is about to be created!") "," Infor ", MB_OK);
}
Break
Case Wm_destroy:
{
PostQuitMessage (0);
}
Break
}
return DefWindowProc (Hwnd,umsg,wparam,lparam);
}
Create an entry function
int Apientry WinMain (
HINSTANCE HInstance,
HInstance hPrevInstance,
LPSTR lpCmdLine,
int ShowCmd
)
{
HWND hwnd=0;
MSG nmsg={0};
Register window class
Wndclass cs={0};
cs.cbclsextra=0;
cs.cbwndextra=0;
Cs.hbrbackground= (Hbrush) (color_window+2);
Cs.hcursor=null;
Cs.hicon=null;
Cs.hinstance=hinstance;
Cs.lpfnwndproc= (WNDPROC) WinProc;
Cs.lpszclassname= "Main";
Cs.lpszmenuname=null;
Cs.style=cs_vredraw|cs_hredraw;
RegisterClass (&CS);//Implement Registration window
Create window
Hwnd=createwindow ("Main", "Windows", ws_overlappedwindow,200,200,500,500,null,null,hinstance,null);
Display window
ShowWindow (hwnd,sw_show);
Update window
UpdateWindow (HWND);
Message loops
while (GetMessage (&nmsg,0,null,null))
{
TranslateMessage (&NMSG);
DispatchMessage (&NMSG);
}
return 0;
}

Specific steps for Windows window creation

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.