delphi将程序最小化至右下角
程序新手,如果有不恰当的地方,请大家帮忙改正!
1、下载并安装Raize.v5.5控件,delphi版本为:delphi 7.0。
2、添加RzTrayIcon控件、PopupMenu控件至窗体上。
3、程序代码示例:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms,
Dialogs, RzTray, ImgList, Menus;
type
TForm1 = class(TForm)
RzTrayIcon1:
TRzTrayIcon;
PopupMenu1:
TPopupMenu;
N1:
TMenuItem;
ImageList1:
TImageList;
procedure
N1Click(Sender: TObject);
procedure
FormClose(Sender: TObject; var Action: TCloseAction);
procedure
FormCreate(Sender: TObject);
private
{ Private
declarations }
public
{ Public
declarations }
isclos
:boolean; //用于判断是否退出程序
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.N1Click(Sender: TObject);
begin
isclos :=
true;
form1.Close;
end;
procedure TForm1.FormClose(Sender: TObject; var Action:
TCloseAction);
begin
if isclos
then //如果要退出程序,isclos必须为真
begin
action :=
cafree;
end
else begin
action := canone;
application.Minimize;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
isclos :=
false; // 将程序退出判断设为false,即不退出程序
end;
end.
http://blog.sina.com.cn/s/blog_9e8dc58901011uzs.html