Convert message ID to a string

I’ve always wanted something to do this, but never got around to doing it.
Well I found code deep in the mfc that does what i wanted, but i had to cut and paste it cause its not really reusable.
Any this is how you use it:

CWindowsMessageToString msgConverter;
LPSTR lpszMsg = msgConverter.GetStringFromMsg( WM_COMMAND );
MessageBox( lpszMessage );

This would pop up a messagebox that would say “WM_COMMAND”.

I think this class will be useful when you have a function that is handling many messages like PreTranslateMsg.
You can also pass 0 as the second parameter to GetStringFromMsg to prevent the function from returning strings
for frequently send message.

Download source – 2KB

Date Posted: 08/27/98

More by Author

Must Read