One of the simplest Windows MFC programming procedures

Source: Internet
Author: User

/*************************************** ***********
One of the simplest Windows MFC programming procedures
**************************************** ***********/
// Use the MFC header file
# Include <afxwin. h>

/*
Note:
Enable the program to use the MFC class library and select "Settings" in the "project" menu ". Select the General tab in the displayed dialog box. In the "Microsoft function class" combo box, select "use MFC in a shared DLL ". Then close the dialog box.
*/
// A new class is derived from the cwinapp class, which represents the current application. All features of this program are embodied in this class.
Class chelloapp: Public cwinapp
{
Public:
Virtual bool initinstance ();
};

// Create an object example. In a Windows application, one application has only one object generated from cwinapp or its derived class.
// The cwinapp class encapsulates winsdk's global functions winmain () and Windows message loop
Chelloapp theapp;

// Because Windows have various appearances and features, MFC does not include windows in the cwinapp class zhogn
// Here is the main window class for creating windows
Class chellowindow: Public cframewnd
{
Public:
Chellowindow ();
};

// The Windows application initialization does not use the constructor of the cwinapp class and its derived classes, but uses a virtual function virtual bool initinstance () to initialize the application.
// If this function returns true, the program continues to execute. If false is returned, the program exits.
Bool chelloapp: initinstance ()
{
// The variable m_pmainwnd has been defined in cwinapp, and its function is to point to the main window of the application.
M_pmainwnd = new chellowindow ();
// Display window
M_pmainwnd-> showwindow (m_ncmdshow );
// Update the control status in the window
M_pmainwnd-> updatewindow ();

Return true;
}

 

// Note that the CREATE () function must be called to create the window itself in the window constructor.
Chellowindow: chellowindow ()
{
Create (null, "one of the simplest MFC programs in Windows MFC programming", ws_overlappedwindow, crect (200,200 ));
}
/*
The process of creating a team image in MFC:
1. Define object types and allocate space
Example: m_pmainwnd = new chellowindow ();
2. Create of the call class itself
For example, create (null, "one of the simplest MFC programs in Windows MFC programming", ws_overlappedwindow, crect (200,200 ));
*/

 

 

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.