//响应图标消息 procedure TForm1.mousemessage(var message: TMessage); message MouseMsg;procedure TForm1.mousemessage(var message: TMessage); var mousept:TPoint; begin inherited; if message.LParam = wm_rbuttonup//系统栏图标上点击右键 then begin GetCursorPos(mousept); PopupMenu1.Popup(mousept.X,mousept.Y);//弹出右键菜单 end; if message.LParam = wm_lbuttonup//系统栏图标上点击左键 then begin ShowWindow(Handle, SW_SHOW); ShowWindow(Application.Handle,SW_SHOW); end;end;
托盘程序的缩放(托盘程序的最大化/最小化) CoDelphi.com 摘 要:如何为有托盘图标的窗体添加最大化/最小化的缩放效果 关键字:缩放 效果 最大化 最小化 托盘程序 类 别:API -------------------------------------------------------------------------------- 我们经常看到窗口最大化/最小化时的缩放效果。不幸的是这种效果只能把应用程序缩成应用程序工作栏中的图标,而且表面上似乎没有方法为最小化到托盘区中的程序添加相似的效果。使用Windows API 函数DrawAnimatedRects可以做到。这个函数需要窗口的句柄和两个标明起始和结束屏幕坐标的矩形区域。以下代码说明如何使用这个API函数: unit TestForm;interfaceuses Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls;typeTZoomAction = (zaMinimize, zaMaximize);TfrmTest = class(TForm) procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); private { private declaration } public { public declaration } end;var frmTest: TfrmTest;implementation{$R *.DFM}procedure ZoomEffect(theForm: TForm; theOperation: TZoomAction); var rcStart: TRect; rcEnd: TRect; rcTray: TRect; hwndTray : hWnd; hwndChild: hWnd; begin { 寻找系统托盘区的位置} hwndTray := FindWindow('Shell_TrayWnd', nil); hwndChild := FindWindowEx(hwndTray, 0, 'TrayNotifyWnd', nil); GetWindowRect(hwndChild, rcTray);{点击用于最大化/最小化,并切换起始/结束} if theOperation = zaMinimize then begin rcStart := theForm.BoundsRect; rcEnd := rcTray; end else begin rcEnd := theForm.BoundsRect; rcStart := rcTray; end;{ 以下是关键的部分... } DrawAnimatedRects(theForm.Handle, IDANI_CAPTION, rcStart, rcEnd) end;procedure TfrmTest.FormClose(Sender: TObject; var Action: TCloseAction); begin ZoomEffect(Self, zaMinimize); end;procedure TfrmTest.FormShow(Sender: TObject); begin ZoomEffect(Self, zaMaximize); end;end.
begin
//隐藏窗体
Action := caNone;
ShowWindow(Handle, SW_HIDE);
ShowWindow(Application.Handle,SW_HIDE); ntida.cbSize:=SIZEOF(tnotifyicondata);
ntida.Wnd := Handle;
ntida.uID := 255;
ntida.uFlags := NIF_ICON + NIF_TIP + NIF_MESSAGE;
ntida.uCallbackMessage := MouseMsg;
ntida.hIcon := Application.Icon.Handle;
ntida.szTip:= '芝麻开门';
Shell_NotifyIconA(NIM_ADD,@ntida);
end;
procedure TForm1.mousemessage(var message: TMessage);
message MouseMsg;procedure TForm1.mousemessage(var message: TMessage);
var
mousept:TPoint;
begin
inherited; if message.LParam = wm_rbuttonup//系统栏图标上点击右键
then
begin
GetCursorPos(mousept);
PopupMenu1.Popup(mousept.X,mousept.Y);//弹出右键菜单
end; if message.LParam = wm_lbuttonup//系统栏图标上点击左键
then
begin
ShowWindow(Handle, SW_SHOW);
ShowWindow(Application.Handle,SW_SHOW);
end;end;
CoDelphi.com 摘 要:如何为有托盘图标的窗体添加最大化/最小化的缩放效果
关键字:缩放 效果 最大化 最小化 托盘程序
类 别:API
--------------------------------------------------------------------------------
我们经常看到窗口最大化/最小化时的缩放效果。不幸的是这种效果只能把应用程序缩成应用程序工作栏中的图标,而且表面上似乎没有方法为最小化到托盘区中的程序添加相似的效果。使用Windows API 函数DrawAnimatedRects可以做到。这个函数需要窗口的句柄和两个标明起始和结束屏幕坐标的矩形区域。以下代码说明如何使用这个API函数:
unit TestForm;interfaceuses
Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls;typeTZoomAction = (zaMinimize, zaMaximize);TfrmTest = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ private declaration }
public
{ public declaration }
end;var
frmTest: TfrmTest;implementation{$R *.DFM}procedure ZoomEffect(theForm: TForm; theOperation: TZoomAction);
var
rcStart: TRect;
rcEnd: TRect;
rcTray: TRect;
hwndTray : hWnd;
hwndChild: hWnd;
begin
{ 寻找系统托盘区的位置}
hwndTray := FindWindow('Shell_TrayWnd', nil);
hwndChild := FindWindowEx(hwndTray, 0, 'TrayNotifyWnd', nil);
GetWindowRect(hwndChild, rcTray);{点击用于最大化/最小化,并切换起始/结束}
if theOperation = zaMinimize then
begin
rcStart := theForm.BoundsRect;
rcEnd := rcTray;
end
else
begin
rcEnd := theForm.BoundsRect;
rcStart := rcTray;
end;{ 以下是关键的部分... }
DrawAnimatedRects(theForm.Handle, IDANI_CAPTION, rcStart, rcEnd)
end;procedure TfrmTest.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ZoomEffect(Self, zaMinimize);
end;procedure TfrmTest.FormShow(Sender: TObject);
begin
ZoomEffect(Self, zaMaximize);
end;end.
我等会试试BUDDED的方法吧,但请问atuchina() :