不像SDI/MDI那样,生命一个CWinApp的继承类,重载某些虚函数来实现自定义的行为。
而是直接CWinApp theApp一个这样的对象。
这有什么用呢?

解决方案 »

  1.   

    Every MFC application program has one, and only one, CWinApp derived object. This is the main program's thread, and contains the program's entry point, WinMain(). A call to AfxGetApp() returns a pointer to this object. You should not reference theApp object directly in your program, but use AfxGetApp() instead.
      

  2.   

    既然是MFC,那么必须要有一个CWinApp对象。
      

  3.   

    建立应用程序对象(theApp),就可以产生一个自己需要的窗口
      

  4.   

    这是框架设计的一种考虑。比如:保存GUI下的hInstance、console下的命令行参数、初始化一个临界区等等。
    SDK自定义框架下有时也会把很多常规项目中初始化的工作封装成类去完成,这样只要声明一个全局变量theApp就可以了。