Archived

This topic is now archived and is closed to further replies.

Windows message IDs to text descriptions??

This topic is 5312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there anyway to get a text description a message being processed by a window? I want to output a log of windows messages being sent to my Window and was just wondering if there was an easy way of translating a message Id to it''s text description. Thanks, BrianH

Share this post


Link to post
Share on other sites
You have to do that yourself.

example:>

  

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_ACTIVATE:
logFile.out("WM_ACTIVATE");
break;

case WM_CREATE:
logFile.out("WM_CREATE");
break;
};

return DefWndProc(hWnd, uMsg, wParam, lParam);
}


however a much cleaner approach would be something like this:>


  

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LogMessage(uMsg);

switch(uMsg)
{
// do this and that

};

return DefWndProc(hWnd, uMsg, wParam, lParam);
}

void LogMessage(UINT uMsg)
{
switch(uMsg)
{
case WM_ACTIVATE:
logFile.out("WM_ACTIVATE");
return;

case WM_CREATE:
logFile.out("WM_CREATE");
return;
};
}



if this was what you wanted...

Share this post


Link to post
Share on other sites
Thanks for the replies.

I tried FormatMessage() and it looks like it gets error code strings and general system messages, or something of that sort.

Oh well, its nothing of great importance. I just wanted to see what messages where getting sent around.

Thanks anyways!

-Brian

Share this post


Link to post
Share on other sites
heh, I just come up with a very easy solution, i think...


      
#define STRING_WM_ACTIVATE "WM_ACTIVATE"

#define STRING_WM_CREATE "WM_CREATE"

#define Message2String(msg)STRING_##msg


LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
logFile.out(Message2String(uMsg));
switch(uMsg)
{
// do whatever...

};
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}



[edited by - pag on May 27, 2003 3:33:12 PM]

Share this post


Link to post
Share on other sites