Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i m new to vc++.
i m so confused about how mfc program runs?
i m not getting who calls winmain()?
would u give me brief description plz?
Posted
Updated 14-Feb-10 0:06am
v2

Kernel calls WinMainCRTStartup function, and WinMainCRTStartup calls WinMain, and WinMain calls AfxWinMain.
 
Share this answer
 
WinMain is defined in a file called appmodul.cpp which is part of the MFC source.

The CRT startup will call this WinMain as posted by Jast_in.
This WinMain then calls a global MFC function called AfxWinMain which then goes on to call your CWinApp derived class' InitInstance method.

If you have a dialog based application, you call DoModal in InitInstance and then return FALSE so that no further processing happens.

If you have a SDI or MDI application, the control enters a Run function called from AfxWinMain after calling InitInstance.

This Run method contains the message loop needed to dispatch Windows messages to the window procedure.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900