5
54sheep
Unregistered / Unconfirmed
GUEST, unregistred user!
我最近做了一个闹钟程序,在windows启动时就自动加载该程序到任务栏!但是我却发现一个问题,每次加载ico图标的时候,windows就会弹出一个对话框,提示:Can not open file 'disable.ico'.但是如果你在源程序中把载入图标的两句给删掉又不会出问题,下面是我的部分源代码!哪位高手能帮我解答一下,谢谢!
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus,Registry,shellapi, ExtCtrls,IniFiles;
const
ICON_ID=1;
MI_ICONEVENT=WM_USER+1;
private
NormalIcon,DisabledIcon:TIcon;
Clock1,Clock2,Status:Boolean;
procedure InstallIcon;
procedure UnInstallIcon;
procedure IconOnClick(var message:TMessage); message MI_ICONEVENT;{ Private declarations }
public
{ Public declarations }
end;
procedure TForm1.InstallIcon;
var
IconData:TNotifyIconData;
begin
NormalIcon:=TIcon.Create;
DisabledIcon:=TIcon.Create;
NormalIcon.LoadFromFile('disable.ico');
IconData.cbSize:=SizeOf(IconData);
IconData.Wnd:=Handle;
IconData.uID:=ICON_ID;
IconData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
IconData.uCallbackMessage:=MI_ICONEVENT;
IconData.hIcon:=NormalIcon.Handle;
IconData.szTip:='Yeah! It''s You! 提醒功能';
Shell_NotifyIcon(NIM_ADD,@IconData);
end;
procedure TForm1.UnInstallIcon;
var
IconData:TNotifyIconData;
begin
IconData.cbSize:=SizeOf(IconData);
IconData.Wnd:=Handle;
IconData.uID:=ICON_ID;
Shell_NotifyIcon(NIM_DELETE,@IconData);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Reg:TRegistry;
begin
Status:=True;
InstallIcon;
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus,Registry,shellapi, ExtCtrls,IniFiles;
const
ICON_ID=1;
MI_ICONEVENT=WM_USER+1;
private
NormalIcon,DisabledIcon:TIcon;
Clock1,Clock2,Status:Boolean;
procedure InstallIcon;
procedure UnInstallIcon;
procedure IconOnClick(var message:TMessage); message MI_ICONEVENT;{ Private declarations }
public
{ Public declarations }
end;
procedure TForm1.InstallIcon;
var
IconData:TNotifyIconData;
begin
NormalIcon:=TIcon.Create;
DisabledIcon:=TIcon.Create;
NormalIcon.LoadFromFile('disable.ico');
IconData.cbSize:=SizeOf(IconData);
IconData.Wnd:=Handle;
IconData.uID:=ICON_ID;
IconData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
IconData.uCallbackMessage:=MI_ICONEVENT;
IconData.hIcon:=NormalIcon.Handle;
IconData.szTip:='Yeah! It''s You! 提醒功能';
Shell_NotifyIcon(NIM_ADD,@IconData);
end;
procedure TForm1.UnInstallIcon;
var
IconData:TNotifyIconData;
begin
IconData.cbSize:=SizeOf(IconData);
IconData.Wnd:=Handle;
IconData.uID:=ICON_ID;
Shell_NotifyIcon(NIM_DELETE,@IconData);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Reg:TRegistry;
begin
Status:=True;
InstallIcon;
ShowWindow(Application.Handle,SW_HIDE);
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
end;