Example Delphi
Delphi Examples Collection
Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.
Use System Tray Icon
Author: admin | Category: Form, Tips and Tricks, Windows API
//This is how we can put our application icon to windows system tray bar //First you must set the form1 icon with your .ico file //This is only example to show the application icon when the application launched unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellAPI, Menus; const WM_ICONTRAY = WM_USER + 1; //User-defined message type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private { Private declarations } public { Public declarations } end; var Form1: TForm1; NotifyIconData : TNotifyIconData; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin with NotifyIconData do begin hIcon := Icon.Handle; StrPCopy(szTip, Application.Title); Wnd := handle; uCallbackMessage := WM_ICONTRAY; uID :=1; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; cbSize := sizeof(TNotifyIconData); end; Shell_NotifyIcon(NIM_ADD,@NotifyIconData); SetWindowLong(Application.Handle, GWL_EXSTYLE,WS_EX_TOOLWINDOW); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin Shell_NotifyIcon(NIM_DELETE,@NotifyIconData); Application.ProcessMessages; Application.Terminate; end; end.
Tags: Application, Form, Icon
Post Meta
-
Form, Tips and Tricks, Windows API -
Comments Feed -