Solved

systray question

Posted on 1998-06-07
3
241 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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