像QQ那样,任务栏可以显示多个图标,如何实现
procedure TfrmSubChat.CreateParams(var Params: TCreateParams);begin inherited CreateParams(Params); //Params.ExStyle := Params.ExStyle or WS_Ex_AppWindow or WS_EX_CLIENTEDGE; //Params.ExStyle := Params.ExStyle or WS_Ex_AppWindow; //最上层WS_EX_TOOLWINDOW,WS_EX_TOPMOST //Params.WndParent := GetDesktopWindow; //params.WndParent := 0; //SetWindowLong(Handle,GWL_EXSTYLE,(GetWindowLong(Handle,GWL_EXSTYLE) or WS_EX_APPWINDOW)); //设父属性,0是桌面end;procedure TfrmSubChat.FormCreate(Sender: TObject);begin //SetWindowLong(Handle, GWL_HWNDPARENT, Application.MainForm.Handle);end;
begin
Self.Left := Screen.Width-self.Width;
Self.Top := Screen.Height-self.Height-30;
end;
procedure TFHXMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
KillTrayIcons(self);
end;
procedure TFHXMain.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @FIconData); //删除托盘图标
Shell_NotifyIcon(NIM_MODIFY, @FIconData);
end;
procedure TFHXMain.N1Click(Sender: TObject);
begin
FHXMain.Visible := True; // 显示窗体
SetWindowPos(Application.Handle, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW);
Shell_NotifyIcon(NIM_DELETE, @NotifyIcon); //删除托盘图标
Refresh;
end;
procedure TFHXMain.N2Click(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE, @NotifyIcon);
Refresh;
Application.Terminate;
end;
procedure TFHXMain.SysCommand(var SysMsg: TMessage);
begin
case SysMsg.WParam of
SC_MINIMIZE: //主窗体最小化时
begin
SetWindowPos(Application.Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_HIDEWINDOW);
Hide; // 在义务栏暗藏程序
//正在托盘区显示图标
with NotifyIcon do
begin
cbSize := SizeOf(TNotifyIconData);
Wnd := Handle;
uID := 1;
uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage := WM_NID;
hIcon := Application.Icon.Handle;
szTip := 'HXGOLD';
end;
Shell_NotifyIcon(NIM_ADD, @NotifyIcon); // 正在托盘区显示图本
Refresh;
end;
else
inherited;
end;
end;
procedure TFHXMain.WMNID(var msg:TMessage);
var
mousepos: TPoint;
begin
GetCursorPos(mousepos); //获得鼠标位置
case msg.LParam of
WM_LBUTTONUP: //在托盘区点右键
begin
FHXMain.Visible := not FHXMain.Visible; // 隐示从窗体取可 hexagonal wire mesh,
Shell_NotifyIcon(NIM_DELETE, @NotifyIcon); //隐藏窗体,先删除托盘区的图标
SetWindowPos(Application.Handle, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW);//正在义务栏隐示窗体
Refresh;
end;
WM_RBUTTONUP: pm1.Popup(mousepos.X, mousepos.Y); //点击弹出菜单
end;
end;
procedure TFHXMain.FormShow(Sender: TObject);
begin
//
end;
end.
[解决办法]
真复杂。TRAYICON能做出来吗?
[解决办法]
delphi实现起来比较吃力
[解决办法]
任务栏很多个图标? 不会是聊天窗口吧?
我说个办法,把窗体封装在dll中
主程序调用时创建它即是了,都是独立的窗体,任务栏会显示图标
至于如何通信。这是另外的问题
[解决办法]
是不是得考虑 具体系统环境 啊,,,XP,,2000,,,WIN7,,,估计不一样吧,,
[解决办法]