Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

icon communicating with application

Posted on 1998-06-29
5
Medium Priority
?
137 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 100 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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