Solved

icon communicating with application

Posted on 1998-06-29
5
129 Views
Last Modified: 2010-04-04
How do i make an icon at the taskbar communicate with my applicantion. For example: when i right click on the icon i want to make a popup menu appears.
0
Comment
Question by:lifeson
5 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356264
You mean in the system tray:
Place 3 buttons for Add, Delete and modify the Icon in the TaskBar.
        Place a Popup menu with some items and write the following code:

        uses ShellAPI;
        .
        var IconData :TNotifyIconData;
        ..
        procedure TForm1.bbAddClick(Sender: TObject);
        begin
          with IconData DO
          begin
            cbSize := SizeOf(IconData);
            uFlags := NIF_ICON OR NIF_TIP OR NIF_MESSAGE;
            uID := 0;
            Wnd := Handle;
            szTip := 'This is my Application'+#0;
            hIcon := Application.Icon.Handle;
            uCallBackMessage := WM_USER+$10;
          end;
          if Shell_NotifyIcon(NIM_ADD,@IconData) then MessageBeep(0);
        end;

        procedure TForm1.bbModifyClick(Sender: TObject);
        begin
          with IconData do
          begin
            szTip := 'app is modified'+#0;
            hIcon := LoadIcon(0,IDI_ASTERISK);
          end;
          if Shell_NotifyIcon(NIM_MODIFY,@IconData) then MessageBeep(0);
        end;

        procedure TForm1.bbDeleteClick(Sender: TObject);
        begin
          if Shell_NotifyIcon(NIM_DELETE,@IconData) then MessageBeep(0);
        end;

        procedure TForm1.WndProc(var MyMessage: TMessage);
        var CursorPos: TPoint;
        begin
          IF MyMessage.Msg = WM_USER+$10 THEN
          CASE MyMessage.LParam OF
          WM_RBUTTONUP :
          BEGIN
            GetCursorPos(CursorPos);
            PopupMenu1.Popup(CursorPos.X, CursorPos.Y);
          END;
          WM_LBUTTONDBLCLK :
          ShowMessage('This is my application');
          END;
          INHERITED WndProc(MyMessage);
        end;
0
 

Author Comment

by:lifeson
ID: 1356265
This answer appears in other qustion already. i made this but when i click at the icon, nothing heappens. Please, i want more dettails about it.
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1356266
make sure to write

TForm1= ....
   PROCEDURE WndProc(var MyMessage: TMessage); OVERRIDE; //IMPORTANT... if you don't override, nothing will happen...

Did that solve the problem?
0
 
LVL 3

Accepted Solution

by:
Matvey earned 50 total points
ID: 1356267
http://bes.trendline.co.il/torry/vcl/system/tstrayv1.zip
"By T. J. Sobotka. Adds a system tray icon for your application. "

http://bes.trendline.co.il/torry/vcl/system/systray.zip
"By SCV Systems. The TscvSysTray component places an icon in the Win95 System Tray (lower right corner of taskbar). Mouse events are detected, and returned to the TscvSysTray object, giving you easy access to these messages. When the user clicks your system tray icon, for example, the TscvSysTray object fires an OnClick message."

http://bes.trendline.co.il/torry/vcl/system/astray.zip
"By Andrey Abakumov. ASTrayIcon allows you use icon in Windows Taskbar area (animated and non-animated). Also has ability to remove your task from Taskbar. "

http://bes.trendline.co.il/torry/vcl/system/trayicon.zip
"By Troels Jakobsen. Another tray icon component, but this one generates standard events, where you can actually check for mousebuttons, keystates, cursor position, etc."

http://bes.trendline.co.il/torry/vcl/system/tray11.zip
By Martin Djernæs. TmdTray is a component which offer a icon in the Windows 95 / NT4.0 tray. TmdTray can use icons from resources, accept hotkeys for the PopupMenu used and automaticly update of the tray, when the connected icon is changed. "

-Torry's Delphi page.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356268
As Holger says, Did you write override?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

20 Experts available now in Live!

Get 1:1 Help Now