像“afx_msg"这样的东西吗?VS/MFC 仍在使用装饰器?

2022-01-12 00:00:00 visual-studio c++ mfc

我正在开发一个 MFC 程序,该程序早在 VC6 时代就开始了.当时有一个类向导,它使用一堆装饰器和注释中的标记来解析类文件.

I'm working on an MFC program that started way back in the VC6 days. Back then there was a class wizard that used a bunch of decorators and markup in comments to parse class files.

例如,它会在它维护的消息处理程序前面插入 afx_msg.它会用 //{{AFX_MSG_MAP(TheApp) 和 /}}AFX_MSG_MAP 注释标记一段代码,以帮助它找到它想要处理的消息映射部分.

For example, it would insert afx_msg in front of message handlers that it maintained. It would mark a block of code with //{{AFX_MSG_MAP(TheApp) and /}}AFX_MSG_MAP comments to help it find the parts of the message map it wanted to handle.

AFAIK,这不再需要了.除此之外,类向导还有很多缺点,我们不得不对这些托管块进行大量手动编辑,而且我们从来没有经常使用它.

AFAIK, this isn't needed anymore. Besides that, there were so many shortcomings with the class wizard that we had to do a lot of manual editing of these managed blocks and we never used it very often anyways.

还有其他理由继续使用 afx_msg 及其同类产品吗?

Are there any other reasons to keep using afx_msg and its ilk?

推荐答案

afx_msg 仍然存在,但一直是纯粹的信息.正如你所说的装饰师.它一直被#定义为空字符串.

afx_msg still exists but has always been purely informative. A decorator as you put it. It's always been #defined as an empty string.

自 VS2003 起不再需要 {{ 和 }} 标记:VS 现在足够聪明,可以将内容放在正确的位置,而无需依赖这些标记.您会注意到 VS2003+ 在它创建的项目中不再包含这些行.

the {{ and }} markers are no longer needed since VS2003: VS is now smart enough to put things in the right place without having to rely on these markers. You'll notice that VS2003+ no longer includes these lines in the projects it creates.

相关文章