Solved

systray question

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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