Archived

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

BrianH

Windows message IDs to text descriptions??

Recommended Posts

BrianH    145
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
pag    100
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
Oluseyi    2103
Have you tried FormatMessage? It can search the system for the string associated with a message id (I don''t know if there are any strings associated with regular messages), so it''s worth a try.

Share this post


Link to post
Share on other sites
BrianH    145
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
pag    100
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