Solved

systray question

Posted on 1998-06-07
3
247 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
[X]
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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 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