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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right click notification from TaskBar button

Status
Not open for further replies.

bob2553

Programmer
Aug 29, 2005
5
BE
Hi,

I'd like to know which message are send to the application when the user right click on the application button located in the TaskBar (or AppBar).
I'd like to replace the default windows popup by my own popup menu.

ATT: I don't want to add more items to the system menu but completely replacing it
I'm not referring to an icon in the notification area.

Thank you in advance
Bob
 
procedure ClickTrayIcon(var msg: TMessage); message WM_NOTIFYICON;

procedure TForm1.ClickTrayIcon(var msg: TMessage);
begin
case msg.lparam of
WM_RBUTTONUP, WM_RBUTTONDBLCLK: ppm.Popup;
end;
end;
 
Sorry, I did not see your ATT
(I'm not referring to an icon in the notification area.)...

So forget it...
 
I did some researh and I can't dig something up, I think the problem is that the popup menu is provided by the taskbar app (explorer?) and not by the delphi app itself.
I'm still searching to give you some usefull info...

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks anyway,

As you can see, applications developped with Delphi have a shorter popup menu than other applications. Normally, you can access this button using the application handle :
- to hide it:
ShowWindow(Application.handle, SW_HIDE)
- to add more items:
AppendMenu(GetSystemMenu(Application.handle, False), MFT_STRING,...
- or to make it flashing
FlashWindow(Application.handle, True)

I decided to intercept all messages (Application.OnMessage) but this is not clear to me which one is send before the menu popups

Bob
 
Like I said, the message doesn't appear in Application.OnMessage, Spy+++ indicates a WM_INITMENU and WM_INITMENUPOPUP message but this message is not handled by TApplication. TForm does implement those messages but is only for right click on the form itself...

you are referring to the system menu (left click on form icon), which is not the same as right click on taskbar button.

for more info on systemmenu, look here :

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks.

So, I can get the handle of the taskbar

var
AppData: TAppBarData;
begin
// 'Shell_TrayWnd' is the name of the task bar's window
AppData.Hwnd := FindWindow('Shell_TrayWnd', nil);

But how can i detect a click on the button corresponding to my application ?
 
It seems to be more simple.

Application.HookMainWindow(AppHookFunc);

function XX.AppHookFunc(var Msg: TMessage): boolean;
begin
If Msg.Msg = WM_INITMENU then
Result:= false;
end;

Now, if I click with the right button, no more popup menu is displayed.

But I still don't know how to get the position of the mouse to display my own popup menu at the right location.

Any idea?
 
maybe a mousehook?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top