用户按下窗口最小化按钮,或者任务栏按钮或者系统的显示桌面按钮时,程序能从任务栏上隐藏,像flashget一样,怎么做
解决方案 »
- 新手问题 mrok编译出错 在线等~~~
- 数组值的循环(焦急等待中啊呀~~~~~~~~~)
- 在程序中创建Access表时,字段名与字段类型要相同时怎么处理呀
- 南京某省级外贸公司下属IT公司急聘Delphi程序员
- 高分求简单的目录树算法结构!
- 日期类型的显示?
- 如何判断在一个edit中输入的每一个字符是字母或数字,50分应该不算少吧!!!
- 谁有 李维的分布式多层应用系统 篇的 里的分布式系统结构的截图,或是WORD文件电子书。反正是相关的分布式系统结构截图都可以。
- 菜鸟问题,UP有分!
- 如何让javascript识别用delphi制作的对象
- 翻译一个VB函数。不懂VB,请各位大虾快快救援。
- 简单的adoquery参数问题,请帮手,在线等…
const
wm_trayicon=wm_user+200;
public:
procedure wmsyscommand(var msg:tmessage);message wm_syscommand;
procedure wmtrayicon(var msg:tmessage);message wm_trayicon;
//最小化为系统托盘图标
procedure tform1.wmsyscommand(var msg:tmessage);
var
myicon:tNotifyIconData;
begin
if msg.WParam=SC_MINIMIZE then
begin
with myicon do
begin
cbSize :=sizeof(tnotifyicondata);//纪录需要的内存大小
Wnd :=form1.handle; //最小化窗体的句柄
uID :=0; //托盘图标序号
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;//
uCallbackMessage:=wm_trayicon;
hIcon:=form1.Icon.Handle;
szTip :='系统托盘图标编程示例';
end;
shell_notifyicon(NIM_ADD,@myicon);
form1.Visible :=false;
end
else
begin
//如果是其它的SystemCommand 消息则调用系统缺省处理函数处理之。
DefWindowProc(Form1.Handle,msg.Msg,Msg.WParam,Msg.LParam);
end;
end;
//最小化为图标的回调
procedure tform1.wmtrayicon(var msg:tmessage);
var
myicon:tnotifyicondata;
begin
if msg.LParam=wm_lbuttondown then
begin
with myicon do
begin
cbSize :=sizeof(tnotifyicondata);
Wnd:=form1.Handle;
uID :=0;
uFlags :=NIF_ICON OR NIF_MESSAGE OR NIF_TIP;
uCallbackMessage :=wm_trayicon;
hIcon :=form1.Icon.Handle;
szTip :='系统托盘图标编程示例';
end;
shell_notifyicon(NIM_delete,@myicon);
form1.visible :=true;
showmessage('鼠标左键单击返回');
end;
end;
要的话留下email.
main.Hide;//隐藏窗体;
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
Application.title:='';
Application.Initialze;
Application.CreateForm(TForm1.Form1);
Application.Run;
或在Form1的OnCreate中加入如下代码:
RegisterServiceProcess(GetCurrentProcessID(),RSP_SIMPLE_SERVICE);
unit Unit1;interfaceuses
Windows, Messages, SysUtils,Classes, Controls, Forms,ShellApi;const
MY_TRAY_ICON=0;
WM_TRAYNOTIFY=WM_USER+1;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject); protected
procedure OnMin(Sender:TObject);
procedure WMTrayNotify(Var Msg:TMessage);message WM_TRAYNOTIFY; private
{ Private declarations }
public
{ Public declarations }
NT:TNOTIFYICONDATA;
end;var
Form1: TForm1;implementation{$R *.dfm}//窗体最小化事件
procedure TForm1.OnMin(Sender:TObject);
begin
ShowWindow(Application.Handle,SW_HIDE);
Application.Minimize;
end;//响应鼠标在托盘区图标上的活动事件
procedure TForm1.WMTrayNotify(var Msg:TMessage);
begin
if (Msg.LParam=WM_LBUTTONUP)then
begin
ShowWindow(Application.Handle,SW_SHOW);
Application.Restore;
end;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
with NT do
begin
cbsize:=sizeof(TNOTIFYICONDATA);
WND:=HANDLE;
UID:=MY_TRAY_ICON;
uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
uCallBackMessage:=WM_TRAYNOTIFY;
hIcon:=Icon.Handle;
szTip:='测试程序'#0;
end;
Shell_NotifyIcon(NIM_ADD,@NT); Application.OnMinimize:=OnMin; Application.OnDeactivate:=OnMin;
end;end.
我自己跟据C++Builder 6中的TrayIocn写了一个也可以显示BallonTip可觉得没CoolTrayIcon
好用于是就扔掉了 由时间找回来请各位大虾帮我改一下
ShowWindow(Application.Handle, SW_HIDE);//显示任务条
ShowWindow(Application.Handle, SW_RESTORE);