温故而知新,学习MFC框架如何创建的过程[13]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 liukaven 的 blog

     case ccommandlineinfo::fileopen:                // 忽略

     case ccommandlineinfo::fileprintto:            // 忽略

     case ccommandlineinfo::fileprint:

     case ccommandlineinfo::filedde:

     case ccommandlineinfo::appregister:

     case ccommandlineinfo::appunregister:

     }

     return bresult;

}

进入到processshellcommand,要处理很多种不同命令,我们忽略其它命令,单独看filenew部分。

注意:实际进入到了afxgetapp()->oncmdmsg(id_file_new, 0, null, null)之中。

 

afxgetapp()实际返回了cmditestapp的唯一实例,它从cwinapp – cwinthread – ccmdtarget – cobject 派生而来。我们没有重载oncmdmsg,所以进入到ccmdtargetoncmdmsg处理中。为了研究,我们删减了一些代码。

bool ccmdtarget::oncmdmsg(uint nid, int ncode, void* pextra,

     afx_cmdhandlerinfo* phandlerinfo)

{

     // 这里删减了一些代码

     // determine the message number and code (packed into ncode)

     const afx_msgmap* pmessagemap;

     const afx_msgmap_entry* lpentry;

     uint nmsg = 0;

     // 这里删减了一些代码,处理后 nmsg = wm_command

     // 为了简化,删减了一些断言等。以下循环用于查找处理此消息的入口。

本文关键:温故而知新,学习MFC框架如何创建的过程
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top