I have a question about sending messages using ::SendMessage (). I am trying to communicate between windows using it like so:
Code:
void FirstWindow::SendNotify (unsigned int notification)
{
::PostMessage (HWND_BROADCAST, NOTIFY_WINDOWS, (WPARAM) notification, (LPARAM) identifier);
}
Where the class is:
Code:
class FirstWindow : public AbstractWindow
{
protected:
int identifier;
public:
FirstWindow (const TCHAR *className, int id) : AbstractWindow () { _className = className; identifier = id; }
virtual bool OnCommand (int ctrlId, int notifyCode) { return false; }
virtual bool OnDestroy () { ::PostQuitMessage (0); return false; }
virtual bool OnClose () { ::DestroyWindow (_hwnd); return false; }
virtual bool OnNotify (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
virtual void SendNotify (unsigned int notification);
//Commands to add controls
virtual bool AddComboBox (char *list[], int items, int x, int y, int width, int height, int id);
//Commands to change controls
virtual bool SetComboText (int ctrl, char *list[], int items);
};
and the code to handle the NOTIFY_WINDOWS message is like so:
Code:
bool FirstWindow::OnNotify (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
MessageBox (NULL, "Received Notification!", "HEY!", MB_OK);
return false;
}
Now, for some reason, when I change the first parameter of ::SendMessage to _hwnd, which is the variable for the window within AbstractWindow, I get a notification within that window; however, when I try to use HWND_BROADCAST, it doesn't do anything, even with multiple windows open. if anyone needs more source or code or anything else to help me with this, just say the word!