Comparing CWinApp and main()
Scott Bloom -- sbloom@cris.com Saturday, January 04, 1997 Environment: NT 4.0, Visual C++ 4.2b I"m working on a conversion of a couple MFC Dialog Apps. All these really do is start a bunch of server threads; The dialog allows the user to shutdown, as well as keep CWinApp from terminating immediately by creating a main window. I'm converting these to services, and trying to decided if I need any of the CWinApp related services. This new service app will not need resources, but we will probably want access to MFC classes and objects. How much (if any) overhead is there when deriving your application class from CWinApp as opposed to declaring a main() function? What are the "gotchas" of either option? Thanks, Scott
Mike Blaszczak -- mikeblas@nwlink.com Sunday, January 05, 1997 At 15:41 1/4/97 -0800, Scott Bloom wrote: >Environment: NT 4.0, Visual C++ 4.2b >How much (if any) overhead is there when deriving your application >class from CWinApp as opposed to declaring a main() function? You need to have a CWinApp object in either case, unless you're only going to use the most trivial members of the most trivial MFC classes. Since not having a CWinApp object doesn't make much sense, it's not reasonable to make a comparison of efficiency or size between something that doesn't work and something that does. .B ekiM http://www.nwlink.com/~mikeblas/ <-- trip report central! 95 Honda VFR-750F / 88 Yamaha FZ-700 (damaged) / 94 Mazda RX-7 Serial #00050! / AMA - HRC - VFROC / Wang Dang Wankel I am bored of this talk. It is time now for the dancing! These words are my own - I do not speak on behalf of Microsoft.
Scott Bloom -- sbloom@cris.com Monday, January 06, 1997 >You need to have a CWinApp object in either case, unless you're only >going to use the most trivial members of the most trivial MFC classes. >Since not having a CWinApp object doesn't make much sense, it's not >easonable to make a comparison of efficiency or size between something >that doesn't work and something that does. Is this because the static instance environment (HINSTANCE) aren't set up correctly or another more obscure (to me) reason? Thx, Scott
Mike Blaszczak -- mikeblas@nwlink.com Monday, January 06, 1997 At 00:28 1/6/97 -0800, Scott Bloom wrote: >>You need to have a CWinApp object in either case, unless you're only >>going to use the most trivial members of the most trivial MFC classes. >>Since not having a CWinApp object doesn't make much sense, it's not >>easonable to make a comparison of efficiency or size between something >>that doesn't work and something that does. > >Is this because the static instance environment (HINSTANCE) aren't set >up correctly or another more obscure (to me) reason? Yes. MFC maintains lots of information for you on a per thread and per module basis. If you've not initialized MFC (eg, you don't have a CWinApp or CWinApp-derived object) you can make MFC sick. Sometimes, you can get away without it, but you normally need it. There are three or four KB articles on this subject. .B ekiM http://www.nwlink.com/~mikeblas/ Why does the "new" Corvette look like a 1993 RX-7? These words are my own. I do not speak on behalf of Microsoft.
| Вернуться в корень Архива |