Old 18th July 2008, 18:58   #1
Junior Member
Join Date: Feb 2007
Posts: 15
Tray PopMenu doubts

Hello all,

I'm currently building a very simple plugin to replace the systray icon. It's funcionality is very simple: a different icon will be shown for each song status ("playing", "stopped", "paused").

So far, I was able to create a new icon and display it at the systray. I'm also able to track song status using Winamp API (I query song status once every second) and I can change the icon properly.

Problem is, I want to fully replace the common systray Winamp icon (not the agent). This means that when the user right clicks the icon, a popmenu should be shown.

So, here's what I do:


LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (message == WM_USER + 2707)
switch (LOWORD(lParam))
HMENU HndMenu = (HMENU) SendMessage(plugin.hwndParent, WM_USER, 0, 281);
TrackPopupMenu(HndMenu, 0, xPos, yPos, 0, plugin.hwndParent, NULL);//hwnd, NULL);

The code correctly calls both WM_LBUTTONDOWN and WM_RBUTTONDOWN. The problem is, when I display the popup menu I use mouse coordinates to clip it to the screen. Unfortunately, the coords that I'm getting from the mouse are client coords. I believe those to be relative to the icon, because they are surely 0. So, since xPos=yPos=0, the menu is shown at the top-left of the screen.

So, anyone knows how to properly show the menu just where the mouse is?
HeavyStorm is offline   Reply With Quote
Old 18th July 2008, 19:34   #2
Debian user
(Forum King)
Joel's Avatar
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Mmm, strange...let me re check the code.

* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 18th July 2008, 19:54   #3
Junior Member
Join Date: Feb 2007
Posts: 15
If you want, I'm can post the whole code here. Just want this thing working so I don't leave winamp playing everytime I go drink a cup coffee...

Last edited by HeavyStorm; 18th July 2008 at 20:33.
HeavyStorm is offline   Reply With Quote
Old 18th July 2008, 21:50   #4
Junior Member
Join Date: Feb 2007
Posts: 15
Ok people, I've solved it.

I was using

xPos = LOBYTE(lParam);
yPos = HIBYTE(lParam);

to get mouse position. No ideia why (should I know that?) this doesn't work properly. I replaced it with "GetCursorPos" and it worked ok.

I've also remembered to insert a SetForegroundWindow before the TrackPopupMenu call.
HeavyStorm is offline   Reply With Quote
Old 2nd August 2008, 20:42   #5
Major Dude
TomyLobo's Avatar
Join Date: Feb 2004
Location: Germany
Posts: 580
switch (LOWORD(lParam))
xPos = LOBYTE(lParam);

see any similarities?

also, the x position is obtained using
xPos = GET_X_LPARAM(lParam);
according to msdn.

in this case, however, you cant do that, since you do not have the actual message's lParam

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump