Solved

systray question

Posted on 1998-06-07
3
242 Views
Last Modified: 2010-04-04
I have added and deleted an icon from the systray, but I am curious how to make the code respond when right clicking or left clicking on the icon.  In other words lets say I want to execute showmessage('test') when someone right clicks on the icon.  How do I do this? How do I intercept when this click takes place?
            Thanks
0
Comment
Question by:jexd99
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1351307
Hi

You should have a WndProc which receives the messages.  If you don't, you can create a component and a WndProc for it.  You will probably inherit from TComponent, so you will need to allocate a handle to your component:

constructor TMyTrayComp.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FHandle := AllocateHWnd(WndProc);
end;

Your WndProc will then look something like this:

procedure TMyTrayComp.WndProc(var AMsg: TMessage);
begin
  try
    with AMsg do
      if (Msg = CM_TRAYICON) then
        begin
          case AMsg.lParam of
            WM_LBUTTONDBLCLK:
              ShowMessage('Double-click');
            WM_LBUTTONUP:
              ShowMessage('Left Click');
            WM_RBUTTONUP:
              ShowMessage('Right Click');
          end;
        end
      else
        Result := DefWindowProc(FHandle, Msg, wParam, lParam);
  except
    Application.HandleException(Self);
  end;
end;

If any of this is a bit vague, I have a tray icon component that I can e-mail to you if you provide your e-mail address.

Regards,
JB
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1351308
0
 

Author Comment

by:jexd99
ID: 1351309
Thanks a bunch :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now