CWINAPP :: InitInstance

zhaozj2021-02-08  282

CWINAPP :: InitInstance Virtual Bool InitInstance ();

return value

Returns a non-zero value if initialization is successful; otherwise it returns 0.

Comment

Windows allows several copies of the program to be run at the same time. In concept, the initialization of the application can be divided into two parts: one-time application initialization work, which is completed at the first time of the application, and the initialization of the instance, each running a copy of each run Execute these operations, including the first time. Winmain implementation calling this function in the frame.

Reloading InitInstance to initialize each new instance of the application running under Windows. Typically, you overload InitInstance to construct the main window object and set the CWINTHREAD:: M_PMAINWND data member to point to this window. See "CWINAPP: Application Class" in the Visual C Programmer Guide for more information on overloading this member function.

Example

// AppWizard implements the overloaded InitInstance function based on the option you selected.

// For example, the single document interface (SDI) option is selected for the code created by AppWizard below.

/ / You can add additional initialization code that can be performed in the code created by AppWizard.

Bool CmyApp :: InitInstance ()

{

// Standard initialization

// If you don't use these features, and you want to reduce the size of the final executable program,

/ / You should remove unnecessary code from the following initialization routine.

SetDialogbkcolor (); // Set the background color of the dialog to gray.

LoadStdProfileSettings (); // Load standard INI file options (including MRU)

// Register the application's document template. Document template

// is used as a connection between documents, frame windows, and views.

CSINGLEDOCTEMPLATE * PDOCTEMPLATE;

PDOCTEMPLATE = New CSINGLEDOCTEMPLATE

IDR_MAINFRAME,

Runtime_class (cmydoc),

Runtime_class (cmainframe), main frame window of // SDI

Runtime_class (cmyview));

AddDDOCTemplate (pdoctemplate);

// Create a new (empty) Document

ONFileNew ();

IF (m_lpcmdline [0]! = '/ 0')

{

// Create a new (empty) document

}

Return True;

}

Cwinapp Overview | Class Members | Hierarchy Chart

转载请注明原文地址:https://www.9cbs.com/read-3415.html

New Post(0)