[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppRegisterWindowMessage
The returned message value can be used when calling the SendMessage or PostMessage function.
Note #1: Although there may be multiple instances of AafMessages, the same message values will be registered! Due to this, I could make all member variables public and const without problem.
Note #2: I obtained the example with the TEXT macro around the message keys. If the example above does not work, perhaps you will have to use it, e.g.:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppRegisterWindowMessage
(C++ Win32 API) RegisterWindowMessage
The RegisterWindowMessage function defines a new window message that is guaranteed to be unique throughout the system. When the message name is already registered, the message number of that existing name will be used.The returned message value can be used when calling the SendMessage or PostMessage function.
Example
A class storing message values I use in a game called 'Amino Acid Fighter':
typedef unsigned int UINT;
struct AafMessages
{
public:
AafMessages() :
titleStart( RegisterWindowMessage("titleStart" )),
titleEnd( RegisterWindowMessage("titleEnd" )),
mainMenuStart(RegisterWindowMessage("mainMenuStart")),
mainMenuEnd( RegisterWindowMessage("mainMenuEnd" )),
gameStart( RegisterWindowMessage("gameStart" )),
gameEnd( RegisterWindowMessage("gameEnd" ))
{
//Nothing left to initialize...
}
const UINT titleStart;
const UINT titleEnd;
const UINT mainMenuStart;
const UINT mainMenuEnd;
const UINT gameStart;
const UINT gameEnd;
};
Note #1: Although there may be multiple instances of AafMessages, the same message values will be registered! Due to this, I could make all member variables public and const without problem.
Note #2: I obtained the example with the TEXT macro around the message keys. If the example above does not work, perhaps you will have to use it, e.g.:
titleStart(RegisterWindowMessage(TEXT([/b]"titleStart"))),
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
