Здравствуйте, volkl, Вы писали:
V>Помогите мне,please,сделать сворачивание в трею!!!
V>Заранее спасибо!
Лень выдирать отдельные куски, думаю тут и так все понятно
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ShellAPI, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure NotifyIcon(var Msg : TMessage);message WM_USER + 100;
procedure OnMinimize(Sender:TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
data:Tnotifyicondata;
implementation
{$R *.DFM}
procedure TForm1.Onminimize(sender:tobject);
begin
showwindow(application.handle,SW_HIDE);
Shell_NotifyIcon(NIM_ADD, @data);
end;
procedure TForm1.NotifyIcon(var msg:TMessage);
begin
application.OnMinimize:=onminimize;
case msg.lparam of
WM_LBUTTONDBLCLK :
begin
application.Restore;
application.BringToFront;
Shell_NotifyIcon(NIM_DELETE, @data);
end;
WM_RBUTTONDOWN: form1.caption:='Key';
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon(NIM_DELETE, @data);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var p:array[0..63] of char;
begin
strpcopy(data.szTip,timetostr(time));
Shell_NotifyIcon(NIM_MODIFY,@data);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
application.onminimize:=onminimize;
with data do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := self.Handle;
uID := 100;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage := WM_USER+100;
hIcon := application.Icon.Handle;
szTip := 'Хыхы';
end;
end;
end.