Basic VC window code

Source: Internet
Author: User
Code

  
Include < Windows. h >

/* Declare windows procedure */
Lresult callback windowprocedure (hwnd, uint, wparam, lparam );

/* Make the class name into a global variable */
Char Szclassname [] = " This is Chinese " ;

Int Winapi winmain (hinstance hthisinstance,
Hinstance hprevinstance,
Lpstr lpszargument,
Int Ncmdshow)
{
Hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
Wndclassex wincl; /* Data structure for the windowclass */

/* The window structure */
Wincl. hinstance = Hthisinstance;
Wincl. lpszclassname = Szclassname;
Wincl. lpfnwndproc = Windowprocedure; /* This function is called by Windows */
Wincl. Style = Cs_dblclks; /* Catch double-clicks */
Wincl. cbsize = Sizeof (Wndclassex );

/* Use default icon and mouse-pointer */
Wincl. hicon = Loadicon (null, idi_application );
Wincl. hiconsm = Loadicon (null, idi_application );
Wincl. hcursor = Loadcursor (null, idc_arrow );
Wincl. lpszmenuname = NULL; /* No menu */
Wincl. cbclsextra = 0 ; /* No extra bytes after the window class */
Wincl. cbwndextra = 0 ; /* Structure or the window instance */
/* Use Windows's default color as the background of the window */
Wincl. hbrbackground = (Hbrush) color_background;

/* Register the window class, and if it fails quit the program */
If ( ! Registerclassex ( & Wincl ))
Return 0 ;

/* The class is registered, let's create the program */
Hwnd = Createmediawexa (
0 , /* Extended possibilites for variation */
Szclassname, /* Classname */
" This is still Chinese " , /* Title text */
Ws_overlappedwindow, /* Default window */
Cw_usedefault, /* Windows decides the position */
Cw_usedefault, /* Where the window ends up on the screen */
544 , /* The programs width */
375 , /* And height in pixels */
Hwnd_desktop, /* The window is a child-window to desktop */
Null, /* No menu */
Hthisinstance, /* Program instance Handler */
Null /* No window creation data */
);

/* Make the window visible on the screen */
Showwindow (hwnd, ncmdshow );

/* Run the message loop. It will run until getmessage () returns 0 */
While (Getmessage ( & Messages, null, 0 , 0 ))
{
/* Translate virtual-key messages into character messages */
Translatemessage ( & Messages );
/* Send message to windowprocedure */
Dispatchmessage ( & Messages );
}

/* The program return-value is 0-the value that postquitmessage () gave */
Return Messages. wparam;
}


/* This function is called by the Windows function dispatchmessage () */

Lresult callback windowprocedure (hwnd, uint message, wparam, lparam)
{
Switch (Message) /* Handle the messages */
{
Case Wm_destroy:
Postquitmessage ( 0 ); /* Send a wm_quit to the Message Queue */
Break ;
Default : /* For messages that we don't deal */
Return Defwindowproc (hwnd, message, wparam, lparam );
}

Return 0 ;
}

 

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.