Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

systray question

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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