Note that there are some explanatory texts on larger screens.

plurals
  1. POMacro definition for message mapping
    primarykey
    data
    text
    <p>Formerly I <a href="https://stackoverflow.com/questions/1863158/message-map-in-win32-no-mfc">asked a question</a> and got a fair response. But I am stucked with below macro definitions.</p> <p>The below definitions generates a Message Map function like it is in MFC Message Map. But the code below does not compile.</p> <p>Whole statements starting with <code>this-&gt;</code> are problematic ones except the one in MSG_HANDLER <code>this-&gt;meth(msg);</code> dont know why..</p> <p>Hence what can be done to correct this issue? </p> <p>I use VS 2008.</p> <pre><code>#define MSG_UNPACK(var, id, msg) x##id *var = (x##id *)(msg); #define BEGIN_MSG_MAP \ protected: \ virtual void dispatchToMsgMap(xMessage *msg)\ { \ if (msg-&gt;msg.message == WM_NULL) \ { \ return; \ } #define MSG_HANDLER(meth, wm_msg) \ else if (msg-&gt;msg.message == wm_msg) \ { \ this-&gt;meth(msg); \ return; \ } #define END_MSG_MAP(base) \ else if (msg-&gt;msg.message == WM_COMMAND) \ { \ this-&gt;dispatchToCmdMap(msg); \ return; \ } \ else if (msg-&gt;msg.message == WM_NOTIFY) \ { \ this-&gt;dispatchToNotifyMap(msg); \ return; \ } \ \ base::dispatchToMsgMap(msg); \ }; #define BEGIN_CMD_MAP \ virtual void dispatchToCmdMap(xMessage *msg)\ { \ MSG_UNPACK(Cmd, WM_COMMAND, msg); \ \ if (Cmd-&gt;ItemID == 0) \ { \ /* not allowed */ \ } #define CMD_HANDLER(meth, cmd_id) \ else if (Cmd-&gt;ItemID == cmd_id) \ { \ this-&gt;meth(Cmd-&gt;ItemID); \ } #define END_CMD_MAP(base) \ else \ { \ base::dispatchToCmdMap(msg); \ } \ }; </code></pre> <p>Here, for example <code>this-&gt;dispatchToCmdMap(msg); \</code> is 41st line.</p> <p>1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(41) : error C2059: syntax error : 'this' 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(41) : error C2017: illegal escape sequence 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(42) : error C2059: syntax error : 'return' 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(42) : error C2017: illegal escape sequence 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(43) : error C2059: syntax error : '}' 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(43) : error C2143: syntax error : missing ';' before '}' 1>d:\devel\coding\vs2008\test2\test2\messagemapper.h(43) : error C2059: syntax error : '}'</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload