Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

windows message from system tray icon

Status
Not open for further replies.

ScrumpyJackk

Programmer
Mar 31, 2005
7
ES
Hey
I have made an application that is minimised to the system tray. What I cannot seem to work out is how to capture windows messages from the system tray icon so I can do things like open a popup menu.

Any help would be appreciated.
Jack
 
Ok, so I've worked that one out. I used the macros to specify a custom message handler for my custom windows message type that I specified when I created the system tray icon.

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(msg code, msg obj, msg handler method)
END_MESSAGE_MAP(TForm)

So now I just need to figure out how to get the mouse coordinates. In a normal WM_RBUTTONDOWN message is contains the coordinates but I receive my system tray icon custom message, this specifies the mouse event type in the LParam, but doesn't specify the coordinates.
Does anyone know how to get the mouse coordinates from windows?
It would be easy with Visual C++ but there I can't find anything in BCB5. Only if the cursor is in the form but the form is hidden so that doesn't help.
 
From what I understand on this, you want to track Window's messages. There is an article that might help. See: .

Look for the Augmenting the WndProc Member Function section for an example of how to track mouse coordinates.

James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
I found the WinAPI function call for the cursor positon.
So my code to open a popup after a the tray icon is clicked is:

POINT WinPoint;
GetCursorPos(&WinPoint);
PopupMenu1->Popup(WinPoint.x,WinPoint.y);

:D
Jack

ps Thanks for the feedback 2ffat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top