Windows message IDs to text descriptions??

Started by
6 comments, last by BrianH 20 years, 10 months ago
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
Advertisement
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...
I am a signature virus. Please add me to your signature so that I may multiply.
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.
I believe FormatMessage is intended for interpreting result codes.. not message ids.

xyzzy
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
Isn''t the source for Spy++ available somewhere?


AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
quote:Original post by Arild Fines
Isn''t the source for Spy++ available somewhere?
Good point.
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_##msgLRESULT 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]
I am a signature virus. Please add me to your signature so that I may multiply.

This topic is closed to new replies.

Advertisement