主题:系统托盘的设置
league
[专家分:0] 发布于 2007-01-19 17:07:00
窗体最小化时怎样做才能让它在系统托盘中显示而不是显示在状态栏中.
就像金山词霸那样.
回复列表 (共2个回复)
沙发
wealthy [专家分:1840] 发布于 2007-01-25 17:09:00
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, shellapi, StdCtrls; //注意这里
const
WM_TRAYNOTIFY = WM_USER+100;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
procedure TrayNotifyMessage(var Sender: TMessage);
message WM_TRAYNOTIFY;
procedure MarkTaskBarIcon(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
tnd: TNOTIFYICONDATA;
implementation
{$R *.dfm}
procedure TForm1.MarkTaskBarIcon(Sender: TObject);
begin
Form1.Visible := False;
tnd.cbSize := sizeof(tnd);
tnd.Wnd := Handle;
tnd.uID := 128;
tnd.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
tnd.uCallbackMessage := WM_TRAYNOTIFY;
tnd.hIcon := Application.Icon.Handle;
StrPCopy(tnd.szTip,Application.Title);
Shell_NotifyIcon(NIM_ADD,@tnd);
end;
procedure TForm1.TrayNotifyMessage(var Sender: TMessage);
begin
if Sender.LParam = WM_LBUTTONDBLCLK then
begin
Form1.Visible := True;
Application.Restore;
Application.BringToFront;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize := MarkTaskBarIcon;
MarkTaskBarIcon(Sender);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon(NIM_DELETE,@tnd);
end;
end.
板凳
糖醋鼻子 [专家分:110] 发布于 2007-02-01 15:58:00
去下载一个叫TrayIcon或者CoolTrayIcon的控件即可
Delphi2006自带此功能的控件
我来回复