Things like afx_msg decorators still used by VS / MFC?

I am working on an MFC program that began in the days of VC6. Then a class wizard appeared who used a bunch of decorators and markup in the comments to analyze class files.

For example, it will insert afx_msg in front of the message handlers that it supports. He will mark the code block with comments // {{AFX_MSG_MAP (TheApp) and /}} AFX_MSG_MAP to help find the parts of the message map that she wanted to process.

AFAIK, this is no longer necessary. In addition, there were so many flaws in the master class that we had to do a lot of manual editing of these managed blocks, and we never used it very often anyway.

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

+7
c ++ visual-studio mfc
source share
4 answers

afx_msg still exists, but has always been purely informative. Decorator, as you put it. It was always #defined as an empty string.

tokens {{and}} are no longer needed with VS2003: VS is now smart enough to put things in the right place without relying on these tokens. You will notice that VS2003 + no longer includes these lines in the projects it creates.

+10
source share

AFAIK, afx_msg is no longer used. Another marker was used to help CW figure out where to put things, and some of them may still be used (for example: location of the message map in .cpp files). In header files, it is probably safer to delete, but I would not choose them arbitrarily.

One thing you could do: run a new MFC project mockup in your current version of VS, add a window class and several handlers, and pay attention to the notations currently created. Everything that is not placed is probably no longer in use, and everything that is still inserted is probably still used in one form or another).

PS: MS knows the problems with the current editing of CW well, and they tell me that they will be largely addressed to VS2010 ... we'll see.

+2
source share

AFAIK is no longer needed. The class wizard in VS2008 will no longer generate comments and will not use existing comments that were generated by previous versions. The class wizard will still generate afx_msg decorators, but they are not used.

My general rule when working with code from VC6 days is to remove all comments, but leave afx_msg decorators. I find decorators useful when reading code to indicate that a method is a message handler.

+1
source share

In VS2008, afx_msg is an empty #define. I removed all other pasted ClassWizard dreck from our application, which was updated from VC6 to 2005. Of course, I also do not use ClassWizard at all.

0
source share

All Articles