Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are things like "afx_msg" decorators still used by VS/MFC?

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?

like image 381
criddell Avatar asked Feb 23 '09 16:02

criddell


3 Answers

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.

like image 57
Serge Wautier Avatar answered Sep 19 '22 11:09

Serge Wautier


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.

like image 24
Nick Avatar answered Sep 23 '22 11:09

Nick


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.

like image 30
Dani van der Meer Avatar answered Sep 21 '22 11:09

Dani van der Meer