{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.insertprocressbar1click(sender: Tobject);
var i,count:integer;
stapanplewidth:integer;
begin
Progress:=Tprogressbar:create(Form1);
conut:=300;
stapanlewidth:=status.panels.items[1].width;
status.panels.items[2].width:=150;
stattus.repaint;
with progress do
begin
top:=statusdrawrect.top;
left:=statusdrawrect.left;
width:=statusdrawrect.right-statusdrawtrect.top;
height:=statusdrawrect.bottom-statusdrawtrect.top;
visible:=true;
try
parent:=status;
min:=0;
max:=count;
step:=1;
for i:=0 to count do step;
showmessage('sdfsdf');
finelly;
free;
edn;
status.panels.itmes[2].width:=stapanelwidth;
end;
procedure TmainForm.installIcon;
var icondata:TNotifyIconData;
begin
normalIcon:=TIcon.Create;
disabledIcon:=TIcon.Create;
normalicon.LoadFromFile ('wang.ico');
disabledIcon.LoadFromFile ('wang1.ico');
IconData.cbSize:=Sizeof(IconData);
IconData.Wnd :=Handle;
IConData.uID :=Icon_ID;
IconData.uFlags :=NIF_ICON or NIF_MESSAGE or NIF_TIP;
IconData.uCallbackMessage :=MyIcoMes;
IConData.hIcon :=normalIcon.Handle ;
IconData.szTip :='fuck';
Shell_NotifyIcon(NIM_ADD,@IconData);
end;
procedure Tmainform.UninstallIcon ;
var
IconData:TNotifyIconData;
begin
//
IconData.cbSize :=Sizeof(IconData);
IconData.Wnd :=handle;
IconData.uID :=ICON_ID;
Shell_NotifyIcon(NIM_DELETE,@IconData);
end;
procedure TmainForm.ChangeIcon(status:boolean);
var
IconData:TNotifyIconData;
begin
IconData.cbSize :=Sizeof(IconData);
IconData.Wnd :=Handle;
IconData.uID :=ICON_ID;
if not status then IconData.hIcon := normalicon.Handle
else IconData.hIcon :=disabledIcon.Handle;
IconData.uFlags :=NIF_ICON;
Shell_NotifyIcon(NIM_MODIFY,@IconData);
end;
procedure TmainForm.FormCreate(Sender: TObject);
begin
installIcon; //建立“托盘”图标
ChangeIcon(False);
ShowWindow(Application.handle,SW_HIDE); //隐藏应用程序主窗口机
end;
procedure Tmainform.MyIcoMesDo(var Msg:TMessage);
Var Mouse_Point : TPoint; //当前鼠标位置
begin
if (Msg.LParam=WM_LBUTTONDBLCLK) and mainform.Enabled then
mainform.Visible:=not mainform.Visible; //双击图标,显示(隐藏)窗口
if (Msg.LParam=WM_RBUTTONUP) and mainform.Enabled then
begin //右键单击,显示菜单
GetCursorPos(Mouse_Point);
main_pop.Popup(Mouse_Point.x,Mouse_Point.y);
ChangeIcon( status );
end;
end;
procedure TmainForm.FormShow(Sender: TObject);
begin
//
end;
procedure TmainForm.FormHide(Sender: TObject);
begin
//
end;
procedure TmainForm.FormDestroy(Sender: TObject);
begin
//
end;
procedure TmainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case key of
18: //弹出pop菜单 "Alt"
begin
GetCursorPos(Mouse_Point);
main_pop.Popup(Mouse_Point.x,Mouse_Point.y);
end;
end;
end;
procedure TmainForm.pop_quitClick(Sender: TObject);
begin
Close;
end;
procedure TmainForm.pop_aboutClick(Sender: TObject);
begin
//
end;
procedure TmainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unInstallIcon; //删除任务栏图标
normalicon.Free ;
disabledIcon.Free;
end;
procedure TmainForm.FormActivate(Sender: TObject);
begin
ShowWindow( Application.Handle, SW_HIDE );
end;
procedure TmainForm.status1Click(Sender: TObject);
begin
status := not status;
if status then status1.Caption := 'Enable'
else status1.Caption := 'Disable' ;
changeIcon(status);
end;