请问:怎么把自己做的delphi程序放到托盘里?? 如题。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 procedure TfmTaskSearcher.FormCreate(Sender: TObject);var nid: TNotifyIconData;begin nid.cbSize := sizeof(nid); nid.Wnd := Handle; nid.uID := 0; nid.hIcon := Application.Icon.Handle; StrPCopy(nid.szTip, pProgamVersion); nid.uCallbackMessage := WM_ICONMESSAGE; nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; if not Shell_NotifyIcon(NIM_ADD, @nid) then begin ShowMessage('System Error!'); Application.Terminate; end;// SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); Caption := pProgamVersion; PageControl1.ActivePageIndex := 0; IniFileName := ExtractFileDir(ParamStr(0)) + '\Config.INI'; CommonFileName := ExtractFileDir(ParamStr(0)) + '\CommonFiles.TXT'; ReadIniFile; ReadTxtFile;end;procedure TfmTaskSearcher.FormClose(Sender: TObject; var Action: TCloseAction);var nid: TNotifyIconData;begin nid.cbSize := SizeOf(nid); nid.uID := 0; nid.Wnd := Handle; Shell_NotifyIcon(NIM_DELETE, @nid);end; 请问以下几段代码是什么意思啊?1: nid.uCallbackMessage := WM_ICONMESSAGE; 2: SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);3: ReadIniFile;4: ReadTxtFile是不是还要调用其它的单元才能运行? 俺来说说要点吧。1、需要使用shellapi单元2、要填一个结构TnotifyIconData = record cbsize:Dword;{结构长度} Wnd:HWND;{调用者的窗口Handle} uID:UINT;{用户自定义参数} uFlags:UINT;{指定哪些字段是有效的:NIF_MESSAGE(callback字段) NIF_ICON(icon字段) NIF_TIP(tip字段) uCallbackMessage:UINT;{发回给程序的消息值} hIcon:HICON;{托盘里显示的图标的Handle} szTip:array[0..63] fo AnsiChar;{图标提示}end;在程序要定义一个TNotifyIconData类型的变量,然后把里面的字段都填好。3、调用Shell_NotifyIcon(dwMessage:DWORD;lpData:PNotifyIconData)函数dwMessage可以为:NIM_ADD 增加一个图标NIM_MODIFY 修改一个图标NIM_DELETE 删除一个图标4、如果需要可以定义一个函数响应一下托盘里发生的事件再看看上面的例子很容易理解。 ... private IniFileName: String; CommonFileName: String; iCount: Integer; function IsValidDir(SearchRec: TSearchRec): Boolean; procedure SearchTask(const sDir, sExtension: String); procedure ViewFinished(const sDir, sExtension: String); procedure SetTimerInterval; procedure ReadIniFile; procedure WriteIniFile; procedure ReadTxtFile; procedure WriteTxtFile; procedure AutoStartWhenOsStart(const IsAutoStart: Boolean); procedure OnIconNotify(var Msg: TMessage); message WM_ICONMESSAGE; procedure OnSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; public { Public declarations } end;implementation...procedure TfmTaskSearcher.OnIconNotify(var Msg: TMessage);var CurPos: TPoint;begin if Msg.LParam = WM_LBUTTONDBLCLK then Show else if Msg.LParam = WM_RBUTTONUP then begin GetCursorPos(CurPos); SysPopMenu.Popup(CurPos.X, CurPos.Y); end else inherited;end;procedure TfmTaskSearcher.OnSysCommand(var Msg: TWMSysCommand);begin if (Msg.CmdType = SC_CLOSE) or (Msg.CmdType = SC_MINIMIZE) then Hide else inherited;end;... NIF_ICON or NIF_TIP or NIF_MESSAGE这几个在哪定义的啊? adocommand控件的异步执行问题 [求助]:ConnectNamedPipe在Win98下面可以用嗎? delphi有没有并口通信的控件? 呵呵,找到了女友,散分!!! 大家祝福一下,谢谢,同时祝福给你们 ---- 3 TabControl 控件的使用————在线等待!!!!急呀!! 触发器(ORACLE)!!!!!!!!! Sizeof有意思 紧急求助,vcl控件,我怎样写属性编辑器 为我们所有的单身程序员搞个招亲网站! 关于<<delphi5.0开发人员指南>>? 怎么样把指针指向当前记录? 求助:在做一个演示程序,请问怎样能够失键盘失效
var
nid: TNotifyIconData;
begin
nid.cbSize := sizeof(nid);
nid.Wnd := Handle;
nid.uID := 0;
nid.hIcon := Application.Icon.Handle;
StrPCopy(nid.szTip, pProgamVersion);
nid.uCallbackMessage := WM_ICONMESSAGE;
nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
if not Shell_NotifyIcon(NIM_ADD, @nid) then
begin
ShowMessage('System Error!');
Application.Terminate;
end;
// SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
Caption := pProgamVersion;
PageControl1.ActivePageIndex := 0;
IniFileName := ExtractFileDir(ParamStr(0)) + '\Config.INI';
CommonFileName := ExtractFileDir(ParamStr(0)) + '\CommonFiles.TXT';
ReadIniFile;
ReadTxtFile;
end;procedure TfmTaskSearcher.FormClose(Sender: TObject; var Action: TCloseAction);
var
nid: TNotifyIconData;
begin
nid.cbSize := SizeOf(nid);
nid.uID := 0;
nid.Wnd := Handle;
Shell_NotifyIcon(NIM_DELETE, @nid);
end;
1: nid.uCallbackMessage := WM_ICONMESSAGE;
2: SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
3: ReadIniFile;
4: ReadTxtFile是不是还要调用其它的单元才能运行?
1、需要使用shellapi单元2、要填一个结构
TnotifyIconData = record
cbsize:Dword;{结构长度}
Wnd:HWND;{调用者的窗口Handle}
uID:UINT;{用户自定义参数}
uFlags:UINT;{指定哪些字段是有效的:NIF_MESSAGE(callback字段) NIF_ICON(icon字段) NIF_TIP(tip字段)
uCallbackMessage:UINT;{发回给程序的消息值}
hIcon:HICON;{托盘里显示的图标的Handle}
szTip:array[0..63] fo AnsiChar;{图标提示}
end;
在程序要定义一个TNotifyIconData类型的变量,然后把里面的字段都填好。3、调用Shell_NotifyIcon(dwMessage:DWORD;lpData:PNotifyIconData)函数
dwMessage可以为:
NIM_ADD 增加一个图标
NIM_MODIFY 修改一个图标
NIM_DELETE 删除一个图标4、如果需要可以定义一个函数响应一下托盘里发生的事件再看看上面的例子很容易理解。
private
IniFileName: String;
CommonFileName: String;
iCount: Integer; function IsValidDir(SearchRec: TSearchRec): Boolean;
procedure SearchTask(const sDir, sExtension: String);
procedure ViewFinished(const sDir, sExtension: String);
procedure SetTimerInterval;
procedure ReadIniFile;
procedure WriteIniFile;
procedure ReadTxtFile;
procedure WriteTxtFile;
procedure AutoStartWhenOsStart(const IsAutoStart: Boolean);
procedure OnIconNotify(var Msg: TMessage); message WM_ICONMESSAGE;
procedure OnSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
public
{ Public declarations }
end;implementation...procedure TfmTaskSearcher.OnIconNotify(var Msg: TMessage);
var
CurPos: TPoint;
begin
if Msg.LParam = WM_LBUTTONDBLCLK then
Show
else if Msg.LParam = WM_RBUTTONUP then
begin
GetCursorPos(CurPos);
SysPopMenu.Popup(CurPos.X, CurPos.Y);
end
else
inherited;
end;procedure TfmTaskSearcher.OnSysCommand(var Msg: TWMSysCommand);
begin
if (Msg.CmdType = SC_CLOSE) or (Msg.CmdType = SC_MINIMIZE) then
Hide
else
inherited;
end;...
这几个在哪定义的啊?