Confused by BEGIN_MSG_MAP and BEGIN_MSG_MAP_EX
I am tracing a bug and I suspect the root could be in the use of WTL macros. When sould I use *_EX and when normal macros. For BEGIN_MSG_MAP_EX there is a note in atlcrack.h
// Note about message maps with cracked handlers:
// For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX.
// For ATL 7.0 o开发者_如何学Cr higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes,
// but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl.
but how about the rest or the macros ? can I use both COMMAND_ID_HANDLER and COMMAND_ID_HANDLER_EX in the same BEGIN_MSG_MAP_EX for example ?
I recommend BEGIN_MSG_MAP_EX because it supports more handlers. It also supports the BEGIN_MSG_MAP handlers.
It will be safer if you add this to your main header file (probably stdafx.h
)
#undef BEGIN_MSG_MAP
#define BEGIN_MSG_MAP BEGIN_MSG_MAP_EX
So now code that is using BEGIN_MSG_MAP
will be translated to BEGIN_MSG_MAP_EX
which is better in every aspect.
精彩评论