刘华世的官方博客

ID_APP_EXIT

标准命令消息ID_APP_EXIT

分类:

 

当用户从“文件”菜单选择执行“退出”时,将发送MFC标准命令消息ID_APP_EXIT。MFC实现的函数CWinApp::OnAppExit()完成对该命令消息的缺省处理。

 

CWinApp::OnAppExit()定义在文件afxwin.h中

 

protected:

      //{{AFX_MSG(CWinApp)

      afx_msg void OnAppExit();

      afx_msg void OnUpdateRecentFileMenu(CCmdUI* pCmdUI);

      afx_msg BOOL OnOpenRecentFile(UINT nID);

      //}}AFX_MSG

      DECLARE_MESSAGE_MAP()

 

 

它对应的消息映射在文件appcore.cpp中

 

BEGIN_MESSAGE_MAP(CWinApp, CCmdTarget)

      //{{AFX_MSG_MAP(CWinApp)

      // Global File commands

      ON_COMMAND(ID_APP_EXIT, &CWinApp::OnAppExit)

      // MRU - most recently used file menu

      ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE1, &CWinApp::OnUpdateRecentFileMenu)

      ON_COMMAND_EX_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, &CWinApp::OnOpenRecentFile)

      //}}AFX_MSG_MAP

END_MESSAGE_MAP()

 

 

实现在文件appui.cpp中

 

void CWinApp::OnAppExit()

{

      // same as double-clicking on main window close box

      ASSERT(m_pMainWnd != NULL);

      m_pMainWnd->SendMessage(WM_CLOSE);

posted @ 2013-03-12 17:39  pythonschool  阅读(1543)  评论(0编辑  收藏  举报
刘华世的官方博客