请教:如何使得程序一运行即自动隐藏(到TrayIcon)? TrayIcon我已实现,但是如何在程序启动后自动隐藏自己?在OnCreate中Visible := False 不行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你设计程序的时候将Form的Visible属性设置为False行不行? unit Unit1;interfaceuses 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. INDY里在TCP如何发送记录集?如何接收? COMM通信 第一个字节丢了 新手请教:关于访问成员数据出错的问题! 长夜漫漫,无心睡眠,还没睡的来接分了 邮件的接收,使用控件:Indy Client 组件里的IdPOP31 如何主动抛出异常? 谁看了<程序员增值合订本>2002年上里面的’编写delphi IDE plug-in 指南一 的请进!! 如何删除adotable中的所有记录?急!!! 南京的开发人员看过来!!! 判断DBGRID是否选中状态 ini文件操作-急 急 急!!!!!!! 救命啊!!!!!!!!!!!!!!!!
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.