hw to declare and use user defined messages and to send them to a another wnd
?
Printable View
hw to declare and use user defined messages and to send them to a another wnd
?
For defining messages:
#define WM_SOME_MESSAGE WM_USER+1
etc.
For sending messages, use PostMessage() or
SendMessage()
It is better to use WM_APP.
Quote:
Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class. These values cannot be used to define messages that are meaningful throughout an application, because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. Messages in this range should not be sent to other applications unless the applications have been designed to exchange messages and to attach the same meaning to the message numbers.
You could use RegisterWindowMessage("AUniqueStringForYourApp") as well.
Although it deals with accessing control (CWnd's) out of a thread, the following FAQ will show how to send a user-defined message...