Disclaimer: I'm new to MFC and have basic knowledge of c++
My question:
I ran into the following code that was auto generated by Visual studio:
afx_msg void OnBnClickedOk();
what does afx_msg
do and are there other like that?
As far as my knowledge goes, there are only a handful of access specifiers like : public
, private
, protected
. There's also virtual
.
I found an answer here but it is still not clear to me.
afx_msg
is an empty macro #define'd in afxwin.h
:
// Type modifier for message handlers
#ifndef afx_msg
#define afx_msg // intentional placeholder
#endif
The code will compile and work the same with or without afx_msg
, but it is used by convention as an indicator that the function is a message handler, and is required if using the class wizard, per TN006: Message Maps:
ClassWizard requires that you use the afx_msg keyword in your message map handler declarations.
The code in afxwin.h
is just:
// Type modifier for message handlers
#ifndef afx_msg
#define afx_msg // intentional placeholder
#endif
it is, or might have been, a help for the wizards to recognize the code.
It doesn't do anything else.
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