TrayIcon我已实现,但是如何在程序启动后自动隐藏自己?
在OnCreate中Visible := False 不行
在OnCreate中Visible := False 不行
解决方案 »
- 设置dbgrid的columns中的fieldname属性时,弹出ADOquery1 missing SQL property是怎么回事?
- dll封装子窗体(含ado)报 access violation at dress xxx in module 'project1.dll'错
- [请教]创建一个多级目录,并且用Treeview实现这个目录结构
- 怎么获取application.MessageBox()的返回值?分别有哪些返回值?
- 不难的两个问题,入门级:1.关于自增量字段 2.关于执行存储过程
- 谁知道有哪个控件可以实现将文件压缩成zip的功能吗?
- 对DELPHI的控件 面板点右键,把他的属性打开
- 创建access数据库
- 在线等待!急!高手请进!100分
- 纯属胡说八道
- 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.