afxwinmian函数里面
有一步是pthread->initinstance();
后面紧跟着就是pthread->run();
这个initinstance完成了所有的关于窗口的设计,注册和创建吗?
查了下,貌似这些都是在CMainFrame类里面的PreCreateWindow()里面完成的
然后我又去找了下CWINAPP类里面的initinstance()函数,没看到有调用CMainFrame类里面的PreCreateWindow()函数的代码啊,求大侠指教

解决方案 »

  1.   

    MFC的代码还是隐藏的有点深
    你首先要对重载有很深刻的了解才可以知道
    你看一下MFC的类库结构,然后再看看源代码
    不一定在CWinApp里调用CMainFrame函数,有可能在它的父类或者父类的父类中调用
      

  2.   

    真想知道的话,请看《深入浅出MFC》吧
      

  3.   

    int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine, int nCmdShow)
    {
    ASSERT(hPrevInstance == NULL); int nReturnCode = -1;
    CWinThread* pThread = AfxGetThread();
    CWinApp* pApp = AfxGetApp(); // AFX internal initialization
    if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
    goto InitFailure; // App global initializations (rare)
    if (pApp != NULL && !pApp->InitApplication())
    goto InitFailure; // Perform specific initializations
    if (!pThread->InitInstance())
    {
    if (pThread->m_pMainWnd != NULL)
    {
    TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
    pThread->m_pMainWnd->DestroyWindow();
    }
    nReturnCode = pThread->ExitInstance();
    goto InitFailure;
    }
    nReturnCode = pThread->Run();
    //==================================================================
    CWinThread::InitInstance
    virtual BOOL InitInstance( );Return ValueNonzero if initialization is successful; otherwise 0.ResInitInstance must be overridden to initialize each new instance of a user-interface thread. Typically, you override InitInstance to perform tasks that must be completed when a thread is first created. This member function is used only in user-interface threads. Perform initialization of worker threads in the controlling function passed to AfxBeginThread.
      

  4.   

    各位大大,我现在就卡在不知道 哪一个类调用了AfxWinMain()这个全局函数,是CWINAPP的initinstance()吗?
      

  5.   

    AfxWinMain()是在构造完theApp对象完成之后由系统调用的,没有在那个类中,MFC封装比较深层!