The ins and outs of the MFC Program-subdocument 2

Source: Internet
Author: User

The ins and outs of the MFC Program-subdocument 2

Afxwininit (hinstance, hprevinstance, lpcmdline, ncmdshow)

View the afxwininit source code:

Bool afxapi afxwininit (_ in _ hinstance, _ in _ hinstance hprevinstance,

_ In_z _ lptstr lpcmdline, _ in _ int ncmdshow)

{

Assert (hprevinstance = NULL );

// Handle critical errors and avoid windows message boxes

Seterrormode (0) |

Sem_failcriticalerrors | sem_noopenfileerrorbox );

// Set resource handles

Afx_module_state * pmodulestate = afxgetmodulestate ();

Pmodulestate-> m_hcurrentinstancehandle = hinstance;

Pmodulestate-> m_hcurrentresourcehandle = hinstance;

Pmodulestate-> createactivationcontext ();

// Fill in the initial state for the Application

Cwinapp * PAPP = afxgetapp ();

If (PAPP! = NULL)

{

// Windows specific initialization (not done if no cwinapp)

PAPP-> m_hinstance = hinstance;

Hprevinstance; // obsolete.

PAPP-> m_lpcmdline = lpcmdline;

PAPP-> m_ncmdshow = ncmdshow;

PAPP-> setcurrenthandles ();

}

// Initialize thread specific data (for main thread)

If (! Afxcontextisdll)

Afxinitthread ();

// Initialize cwnd: m_pfnnotifywinevent

Hmodule =: getmodulehandle (_ T ("user32.dll "));

If (hmodule! = NULL)

{

Cwnd: m_pfnnotifywinevent = (cwnd: pfnnotifywinevent): getprocaddress (hmodule, "notifywinevent ");

}

Return true;

}

Conclusion: afxwininit completes theapp and some thread initialization operations.

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.