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.
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, 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.
Are there any other reasons to keep using afx_msg and its ilk?
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.
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.
AFAIK, afx_msg is no longer used. The other marker were used to help CW figure out where to put things, and some of them may still be used (eg: message map location in the .cpp files). The ones in the header files are probably more safe to remove, but I wouldn't take them out arbitrarily.
One thing you could do: start a new dummy MFC project in your current VS version, add a window class and a few handlers, and observe the notations currently created. Anything not put in is probably no longer used, and anything still inserted is probably still used in some form).
PS: MS is well aware of the issues with the current CW editing, and I'm told they will be addressed to a large extent in VS2010... we shall see.
AFAIK these are not needed anymore. The class wizard in VS2008 won't generate the comments anymore, and won't use existing comments that were generated by previous versions. The class wizard will still generate the afx_msg decorators but, they are not used.
My general rule when dealing with code from the VC6 days, is to remove all the comments, but to leave the afx_msg decorators. I find the decorators useful when reading the code, to point out that a method is a message handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With