pFaz69
asked on
CWinApp theApp; what's for?
i've frequently asked to myself why Visual C++ 6.0 Wizard for console applications includes always the statement:
//------------------------ ---------- --
// The one and only application object
CWinApp theApp;
//------------------------ ---------- --
It's to let to users the chance to call 'AfxGetApp()->.....', or there's a wiser reason?
//------------------------
// The one and only application object
CWinApp theApp;
//------------------------
It's to let to users the chance to call 'AfxGetApp()->.....', or there's a wiser reason?
ASKER
My console program runs without problems without the code row above) if i don't use funcs like AfxGetApp()); so why Visual C++ Wizard includes always this row?
your console program has a main() function (!) which is called at the execution of the application.
The entry to your MFC application is the creation of an object from your "main" app class (runs as a thread(derived from CWinApp derived from CWinThread)).
nil_dib
The entry to your MFC application is the creation of an object from your "main" app class (runs as a thread(derived from CWinApp derived from CWinThread)).
nil_dib
A CWinApp is necessary because you're using MFC (or, at least, you've asked the console Wizard for MFC support).
It's there to maintain state information for the application and help MFC initialize.
If your application works fine without it, it's because you're not using MFC--or not using enough of MFC--to run into a problem.
..B ekiM
It's there to maintain state information for the application and help MFC initialize.
If your application works fine without it, it's because you're not using MFC--or not using enough of MFC--to run into a problem.
..B ekiM
ASKER
i'd like to know something more about that. My program is composed by a main() func (!) and five classes: three of them inherites from CWinThread and two from CAsyncSocket: it works pretty well without the 'CWinApp theApp' statement. So: i don't think i'm using little MFC. Maybe the job of 'CWinApp theApp' statement is performed by some other initializations; but witch is exactly this job?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you, abk for your research.
nil_dib