Subscribe to web2feel.com
Subscribe to web2feel.com

Membuat Tray Icon

Diposting oleh Unknown Kamis, 25 Februari 2010

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, shellapi;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);

private
{ Private declarations }

public
{ Public declarations }
end;

const
WM_ICONTRAY = WM_USER + 1;

var
Form1: TForm1;
NotifyIconData : TNotifyIconData;

implementation
{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIconData);
Application.ProcessMessages;
Application.Terminate;
end;

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;

end.