Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to manipulate Icons in the System Tray Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
25-Oct-04
Category
Shell API
Language
Delphi All Versions
Views
250
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
Perevoznyk, Serhiy
Reference URL:
			The taskbar status area is located to the right of the Start button, and provides 
you with status or notification indicators about your programs. Icons with ToolTips 
are typically used as indicators in the taskbar status area. 
To manipulate an icon in the taskbar status area, use the Windows API function 
Shell_NotifyIcon in the Shell32.dll file. This function allows you to add, modify, 
delete, set a ToolTip string, and send a callback message to execute mouse events.

1   unit Unit1;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7     Menus, ShellAPI, StdCtrls;
8   
9   const
10    WM_MYICON    = WM_USER + 1;
11  
12  type
13    TForm1 = class(TForm)
14      PopupMenu: TPopupMenu;
15      miShowForm: TMenuItem;
16      miCloseApplication: TMenuItem;
17      procedure miShowFormClick(Sender: TObject);
18      procedure miCloseApplicationClick(Sender: TObject);
19      procedure FormCreate(Sender: TObject);
20      procedure FormDestroy(Sender: TObject);
21    private
22      { Private declarations }
23      FIconData: TNotifyIconData;
24      procedure WMMYIcon(var message: TMessage); message WM_MYICON;
25      procedure AddIcon;
26    public
27      { Public declarations }
28    end;
29  
30  var
31    Form1: TForm1;
32  
33  implementation
34  
35  {$R *.DFM}
36  
37  { TForm1 }
38  
39  procedure TForm1.AddIcon;
40  begin
41      with FIconData do
42      begin
43        cbSize := SizeOf(FIconData);
44        Wnd := Self.Handle;
45        uID := $DEDB;
46        uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
47        hIcon := Forms.Application.Icon.Handle;
48        uCallbackMessage := WM_MYICON;
49        StrCopy(szTip, PChar(Caption));
50      end;
51      Shell_NotifyIcon(NIM_Add, @FIconData);
52  end;
53  
54  procedure TForm1.WMMYIcon(var message: TMessage);
55  var
56    pt: TPoint;
57  begin
58    case message.LParam of
59      WM_RBUTTONUP:
60      begin
61        if not Visible then
62        begin
63          SetForegroundWindow(Handle);
64          GetCursorPos(pt);
65          PopupMenu.Popup(pt.x, pt.y);
66        end else
67          SetForegroundWindow(Handle);
68      end;
69      WM_LBUTTONDBLCLK:
70        if Visible then
71          SetForegroundWindow(Handle) else
72          Showform1click(nil);
73    end;
74  
75  end;
76  
77  procedure TForm1.miShowFormClick(Sender: TObject);
78  begin
79    ShowModal;
80  end;
81  
82  procedure TForm1.miCloseApplicationClick(Sender: TObject);
83  begin
84    Close;
85  end;
86  
87  procedure TForm1.FormCreate(Sender: TObject);
88  begin
89    AddIcon;
90  end;
91  
92  procedure TForm1.FormDestroy(Sender: TObject);
93  begin
94     Shell_NotifyIcon(NIM_DELETE, @FIconData);
95  end;
96  
97  end.



			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC