新建
上传
首页
助手
最?/div>
资料?/div>
工具

软采用了所谓的

消息映射机制

,来完成不同对象之间消息的传递,本文?/p>

MFC9.0

源码?/p>

行分析,大致讲解

MFC

的消息映射机制?/p>

 

步入正题

?/p>

?/p>

AfxWinMain() 

函数中,

?/p>

MFC

框架初始化完成后?/p>

?/p>

 

pThread->InitInstance() 

执行完成,就开始进行消息循环,入口函数?/p>

pThread->Run()

?/p>

 

[cpp]

 

view plaincopy

 

1.

 

// Perform specific initializations

  

 

2.

 

if

 (!pThread->InitInstance())

// MFC

初始化框?/p>

  

 

3.

 

{  

 

4.

 

    

if

 (pThread->m_pMainWnd != NULL)  

 

5.

 

    {  

 

6.

 

        TRACE(traceAppMsg, 0, 

"Warning: Destroying non-NULL m_pMainWnd\n"

); 

 

 

7.

 

        pThread->m_pMainWnd->DestroyWindow();  

 

8.

 

    }  

 

9.

 

    nReturnCode = pThread->ExitInstance();  

 

10.

 

    

goto

 InitFailure;  

 

11.

 

}  

 

12.

 

nReturnCode = pThread->Run();

// 

进入消息循环

  

 

 

执行

CWinApp:: Run(): 

[cpp]

 

view plaincopy

 

1.

 

// Main running routine until application exits

  

 

2.

 

int

 CWinApp::Run()  

 

3.

 

{  

 

4.

 

    

if

 (m_pMainWnd == NULL && AfxOleGetUserCtrl())  

 

5.

 

    {  

 

6.

 

        

// Not launched /Embedding or /Automation, but has no main window!

  

 

7.

 

        TRACE(traceAppMsg, 0, 

"Warning: m_pMainWnd is NULL in CWinApp::Run -

 quitting application.\n"

);  

 

8.

 

        AfxPostQuitMessage(0);  

 

9.

 

    }  

 

10.

 

    

return

 CWinThread::Run();  

 

11.

 

}  

 

执行

CWinThread::Run(): 

[cpp]

 

view plaincopy

 

Ͼλ
新建
上传
首页
助手
最?/div>
资料?/div>
工具

软采用了所谓的

消息映射机制

,来完成不同对象之间消息的传递,本文?/p>

MFC9.0

源码?/p>

行分析,大致讲解

MFC

的消息映射机制?/p>

 

步入正题

?/p>

?/p>

AfxWinMain() 

函数中,

?/p>

MFC

框架初始化完成后?/p>

?/p>

 

pThread->InitInstance() 

执行完成,就开始进行消息循环,入口函数?/p>

pThread->Run()

?/p>

 

[cpp]

 

view plaincopy

 

1.

 

// Perform specific initializations

  

 

2.

 

if

 (!pThread->InitInstance())

// MFC

初始化框?/p>

  

 

3.

 

{  

 

4.

 

    

if

 (pThread->m_pMainWnd != NULL)  

 

5.

 

    {  

 

6.

 

        TRACE(traceAppMsg, 0, 

"Warning: Destroying non-NULL m_pMainWnd\n"

); 

 

 

7.

 

        pThread->m_pMainWnd->DestroyWindow();  

 

8.

 

    }  

 

9.

 

    nReturnCode = pThread->ExitInstance();  

 

10.

 

    

goto

 InitFailure;  

 

11.

 

}  

 

12.

 

nReturnCode = pThread->Run();

// 

进入消息循环

  

 

 

执行

CWinApp:: Run(): 

[cpp]

 

view plaincopy

 

1.

 

// Main running routine until application exits

  

 

2.

 

int

 CWinApp::Run()  

 

3.

 

{  

 

4.

 

    

if

 (m_pMainWnd == NULL && AfxOleGetUserCtrl())  

 

5.

 

    {  

 

6.

 

        

// Not launched /Embedding or /Automation, but has no main window!

  

 

7.

 

        TRACE(traceAppMsg, 0, 

"Warning: m_pMainWnd is NULL in CWinApp::Run -

 quitting application.\n"

);  

 

8.

 

        AfxPostQuitMessage(0);  

 

9.

 

    }  

 

10.

 

    

return

 CWinThread::Run();  

 

11.

 

}  

 

执行

CWinThread::Run(): 

[cpp]

 

view plaincopy

 

">
新建
上传
首页
助手
最?/div>
资料?/div>
工具

软采用了所谓的

消息映射机制

,来完成不同对象之间消息的传递,本文?/p>

MFC9.0

源码?/p>

行分析,大致讲解

MFC

的消息映射机制?/p>

 

步入正题

?/p>

?/p>

AfxWinMain() 

函数中,

?/p>

MFC

框架初始化完成后?/p>

?/p>

 

pThread->InitInstance() 

执行完成,就开始进行消息循环,入口函数?/p>

pThread->Run()

?/p>

 

[cpp]

 

view plaincopy

 

1.

 

// Perform specific initializations

  

 

2.

 

if

 (!pThread->InitInstance())

// MFC

初始化框?/p>

  

 

3.

 

{  

 

4.

 

    

if

 (pThread->m_pMainWnd != NULL)  

 

5.

 

    {  

 

6.

 

        TRACE(traceAppMsg, 0, 

"Warning: Destroying non-NULL m_pMainWnd\n"

); 

 

 

7.

 

        pThread->m_pMainWnd->DestroyWindow();  

 

8.

 

    }  

 

9.

 

    nReturnCode = pThread->ExitInstance();  

 

10.

 

    

goto

 InitFailure;  

 

11.

 

}  

 

12.

 

nReturnCode = pThread->Run();

// 

进入消息循环

  

 

 

执行

CWinApp:: Run(): 

[cpp]

 

view plaincopy

 

1.

 

// Main running routine until application exits

  

 

2.

 

int

 CWinApp::Run()  

 

3.

 

{  

 

4.

 

    

if

 (m_pMainWnd == NULL && AfxOleGetUserCtrl())  

 

5.

 

    {  

 

6.

 

        

// Not launched /Embedding or /Automation, but has no main window!

  

 

7.

 

        TRACE(traceAppMsg, 0, 

"Warning: m_pMainWnd is NULL in CWinApp::Run -

 quitting application.\n"

);  

 

8.

 

        AfxPostQuitMessage(0);  

 

9.

 

    }  

 

10.

 

    

return

 CWinThread::Run();  

 

11.

 

}  

 

执行

CWinThread::Run(): 

[cpp]

 

view plaincopy

 

Ͼλ">
Ͼλ
Ŀ

关于MFC 消息映射机制剖析 - 百度文库
新建
上传
首页
助手
最?/div>
资料?/div>
工具

软采用了所谓的

消息映射机制

,来完成不同对象之间消息的传递,本文?/p>

MFC9.0

源码?/p>

行分析,大致讲解

MFC

的消息映射机制?/p>

 

步入正题

?/p>

?/p>

AfxWinMain() 

函数中,

?/p>

MFC

框架初始化完成后?/p>

?/p>

 

pThread->InitInstance() 

执行完成,就开始进行消息循环,入口函数?/p>

pThread->Run()

?/p>

 

[cpp]

 

view plaincopy

 

1.

 

// Perform specific initializations

  

 

2.

 

if

 (!pThread->InitInstance())

// MFC

初始化框?/p>

  

 

3.

 

{  

 

4.

 

    

if

 (pThread->m_pMainWnd != NULL)  

 

5.

 

    {  

 

6.

 

        TRACE(traceAppMsg, 0, 

"Warning: Destroying non-NULL m_pMainWnd\n"

); 

 

 

7.

 

        pThread->m_pMainWnd->DestroyWindow();  

 

8.

 

    }  

 

9.

 

    nReturnCode = pThread->ExitInstance();  

 

10.

 

    

goto

 InitFailure;  

 

11.

 

}  

 

12.

 

nReturnCode = pThread->Run();

// 

进入消息循环

  

 

 

执行

CWinApp:: Run(): 

[cpp]

 

view plaincopy

 

1.

 

// Main running routine until application exits

  

 

2.

 

int

 CWinApp::Run()  

 

3.

 

{  

 

4.

 

    

if

 (m_pMainWnd == NULL && AfxOleGetUserCtrl())  

 

5.

 

    {  

 

6.

 

        

// Not launched /Embedding or /Automation, but has no main window!

  

 

7.

 

        TRACE(traceAppMsg, 0, 

"Warning: m_pMainWnd is NULL in CWinApp::Run -

 quitting application.\n"

);  

 

8.

 

        AfxPostQuitMessage(0);  

 

9.

 

    }  

 

10.

 

    

return

 CWinThread::Run();  

 

11.

 

}  

 

执行

CWinThread::Run(): 

[cpp]

 

view plaincopy

 



ļ׺.doc޸Ϊ.docĶ

  • (201112)㶫ʡѧչݻѡ
  • ִѧѧ  (5)¹ʷеѧ
  • tsmװĵ
  • ѧϰ⼯_+
  • л椵
  • ѧѧϰ⼰
  • ʮ塱صĿ-ʵƷĿо - ͼ
  • ˫ͨŵʵ
  • Ⱥ--סԺҳдʿ - ͼ
  • ݾϸȫ汾 - ͼ

վ

԰ Ͼλ
ϵͷ779662525#qq.com(#滻Ϊ@)