如把程序最小化到任务栏中? 当最小化程序时,如何把程序转如后台工作且只在任务栏中显示一个相应的图标? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 showwindow(application.handle,sw_hide);然后再使用 nid.cbSize :=sizeOf(nid); nid.Wnd :=handle; nid.uID := 1; Icon:=TIcon.Create ; nid.hIcon := Icon.Handle ; nid.szTip :='My app'; nid.uCallbackMessage := WM_TrayIcon; nid.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP; Shell_NotifyIcon(NIM_ADD,@nid); uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, AppEvnts, ShellAPI;const SERVER_TRAY_MESSAGE = WM_USER + 100;type TForm1 = class(TForm) ApplicationEvents1: TApplicationEvents; procedure ApplicationEvents1Minimize(Sender: TObject); procedure FormActivate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); private { Private declarations } ServerTrayIconData : TNotifyIconData; procedure ServerTrayMessage(var Message: TMessage); message SERVER_TRAY_MESSAGE; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.ServerTrayMessage(var Message: TMessage);begin if Message.Msg = SERVER_TRAY_MESSAGE then begin case Message.LParam of WM_LBUTTONDBLCLK: begin if IsIconic(Application.Handle) then begin ShowWindow(Application.Handle, SW_NORMAL); SetForegroundWindow(Application.Handle); end; end; end; end;end;procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);begin ShowWindow(Application.Handle, SW_HIDE);end;procedure TForm1.FormActivate(Sender: TObject);begin Application.Minimize;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin Shell_NotifyIcon(NIM_DELETE, @ServerTrayIconData);end;procedure TForm1.FormCreate(Sender: TObject);begin { 托盘 } ServerTrayIconData.cbSize := SizeOf(ServerTrayIconData); ServerTrayIconData.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; ServerTrayIconData.uID := UINT(Self); ServerTrayIconData.Wnd := Handle; ServerTrayIconData.hIcon := Application.Icon.Handle; ServerTrayIconData.szTip := '简单局域网聊天程序服务器端'; ServerTrayIconData.uCallbackMessage := SERVER_TRAY_MESSAGE; Shell_NotifyIcon(NIM_ADD, @ServerTrayIconData);end;end. ShowWindow(Application.Handle, SW_HIDE);可以将应用程序在任务栏的按钮隐藏掉 在Delphi版块中搜索:托盘 包你满意! 能不能用语言描述一下其具体过程和原理,源码太长,而且我对DELPHI不太熟,看起来不是很明白。 怎样实时检测与数据库的连接是否正常 高版本的FastReport(Ver3.05) 可否打开低版本(Ver2.46)的frf文件? 推荐、好歌、进者有分 如何给一个一个data变量赋值 XP下做的程序在98下面窗口显示不正确,怎么办?在线等! dbgrid的列宽如何随列数值宽度动态改变大小?在线? delphi中是否有类似java的容器类型? 各位大侠 救急 难题: TWebBrowser页面编辑问题? (急!!!) 怎么从一个窗口运行到另外一个窗口去? 怎样编程查看本机正在运支的进程? 如何将装入到graphi字段的图片压缩??
nid.Wnd :=handle;
nid.uID := 1;
Icon:=TIcon.Create ; nid.hIcon := Icon.Handle ;
nid.szTip :='My app';
nid.uCallbackMessage := WM_TrayIcon;
nid.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
Shell_NotifyIcon(NIM_ADD,@nid);
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AppEvnts, ShellAPI;
const
SERVER_TRAY_MESSAGE = WM_USER + 100;type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
ServerTrayIconData : TNotifyIconData; procedure ServerTrayMessage(var Message: TMessage); message SERVER_TRAY_MESSAGE;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.ServerTrayMessage(var Message: TMessage);
begin
if Message.Msg = SERVER_TRAY_MESSAGE then
begin
case Message.LParam of
WM_LBUTTONDBLCLK:
begin
if IsIconic(Application.Handle) then begin
ShowWindow(Application.Handle, SW_NORMAL);
SetForegroundWindow(Application.Handle);
end;
end;
end;
end;
end;procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_HIDE);
end;procedure TForm1.FormActivate(Sender: TObject);
begin
Application.Minimize;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Shell_NotifyIcon(NIM_DELETE, @ServerTrayIconData);
end;procedure TForm1.FormCreate(Sender: TObject);
begin
{ 托盘 }
ServerTrayIconData.cbSize := SizeOf(ServerTrayIconData);
ServerTrayIconData.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
ServerTrayIconData.uID := UINT(Self);
ServerTrayIconData.Wnd := Handle;
ServerTrayIconData.hIcon := Application.Icon.Handle;
ServerTrayIconData.szTip := '简单局域网聊天程序服务器端';
ServerTrayIconData.uCallbackMessage := SERVER_TRAY_MESSAGE;
Shell_NotifyIcon(NIM_ADD, @ServerTrayIconData);
end;end.
可以将应用程序在任务栏的按钮隐藏掉