Solved

icon communicating with application

Posted on 1998-06-29
5
133 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
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…

821 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