-
For the user-defined message simply do
#define WM_MYMESSAGE WM_USER + [offset]
replace [offset] by any number > 0 you want.
For MFC:
Add the ON_MESSAGE macro to the message map like this:
Code:
// example for ON_MESSAGE
#define WM_MYMESSAGE (WM_USER + 1)
BEGIN_MESSAGE_MAP( CMyWnd, CMyParentWndClass )
//{{AFX_MSG_MAP( CMyWnd
ON_MESSAGE( WM_MYMESSAGE, OnMyMessage )
// ... Possibly more entries to handle additional messages
//}}AFX_MSG_MAP
END_MESSAGE_MAP( )
OnMyMessage is the message handler function. It must have this prototype:
afx_msg LRESULT OnMyMessage(WPARAM, LPARAM);
-
how can I put the value of WPARAM of LPARAM in a textbox?
VisualPenguin
-
What do those values represent?
-
you said they had to be there, so I've put them there. There has to be a variable that contains the number so I know if someone clicked the icon. In VB these variables are long.
VisualPenguin
-
Yes, I know. The first one is a 32-bit unsigned integer and the second one a 32-bit signed integer. But I can't find what they represent. (One must be some flag what happened: mouse click, move, up, down etc)
-
I know what the lParam can represent. Here is some sample code from my Systray code. It is not MFC though.
PHP Code:
case WM_TRAYNOTIFY: //Used For The Systray Msgs
{
switch(LOWORD(lParam))
{
case WM_LBUTTONDBLCLK: //If Double Click On The Icon
{
BOOL ret;
ret = IsWindowVisible(m_hWnd); //Is Window Already Visable
if(ret)
{
if(m_hWnd_Options != 0x00000000) //If It Is Set Focus To It
SetFocus(m_hWnd);
}
else
{
ShowWindow(m_hWnd,SW_SHOW); //Else Show The Main Window
ShowWindow(m_hWnd_Msg,SW_SHOW); //So The Message List Window
}
break;
} //WM_LBUTTONDBLCLK
case WM_RBUTTONUP: //If A Right Click On The Systray Icon
{
m_SysTray.ShowMenu(); //Show The Systray Menu
break;
} //WM_RBUTTONUP
default:
break;
}
break;
} //WM_TRAYNOTIFY
-
That would work for MFC too, except for the action taken.
Code:
// in message map
ON_MESSAGE(WM_TRAYNOTIFY, OnTrayNotify)
// function
LRESULT CMyWnd::OnTrayNotify(WPARAM wParam, LPARAM lParam)
{
switch(LOWORD(lParam))
{
case WM_LBUTTONDBLCLK:
if(IsWindowVisible())
{
SetFocus();
}
else
{
ShowWindow(SW_SHOW);
m_wndMsg.ShowWindow(SW_SHOW);
}
// ...
}
}