cprogrammer
cprogrammer

Reputation: 5675

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 or 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 ?

Upvotes: 3

Views: 1322

Answers (2)

user603022
user603022

Reputation: 11

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.

Upvotes: 0

Cosmin
Cosmin

Reputation: 21426

I recommend BEGIN_MSG_MAP_EX because it supports more handlers. It also supports the BEGIN_MSG_MAP handlers.

Upvotes: 1

Related Questions