有人知道这种窗口的设置吗? 我想把窗口做成像MSN之类的软件那样,点关闭和最小化的时候都自动隐藏到任务栏,哪位高手知道请指教。希望是API的。急 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 const WM_USERNOTIFY = WM_USER + 1001; TYourMainForm = class(TForm)private FNotifyIconData : TNotifyIconData;public procedure InitNotifyData; procedure AddNotifyIcon; procedure DeleteNotifyIcon; procedure ChangeNotifyIcon;end;procedure TF_AutoBackMain.InitNotifyData;var FIcon: TIcon;begin FIcon:= TIcon.Create; ImageList2.GetIcon(0,FIcon); with FNotifyIconData do begin cbSize := SizeOf(FNotifyIconData); Wnd := Handle; uID := 199999; uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; uCallbackMessage := WM_USERNOTIFY; hIcon := FIcon.Handle; lstrcpy(szTip, PChar(rsTip));// szTip := rsTip; end;end;procedure TF_AutoBackMain.AddNotifyIcon;begin Shell_NotifyIcon(NIM_ADD,@FNotifyIconData);end;procedure TF_AutoBackMain.ChangeNotifyIcon;begin Shell_NotifyIcon(NIM_MODIFY,@FNotifyIconData);end;procedure TF_AutoBackMain.DeleteNotifyIcon;begin Shell_NotifyIcon(NIM_DELETE,@FNotifyIconData);end;procedure TF_AutoBackMain.FormClose(Sender: TObject; var Action: TCloseAction);begin case FCloseChioce of ccClose: begin Action := caFree; end; ccHide: begin Action:= caNone; Hide; AddNotifyIcon; end; end;end; 这样肯定是不行的,哪位高手指点一下啦,是像msn那样的哦。这种icon的做法好像不行。 你看这样行吗?unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private CanExit : Boolean ; { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin CanExit := False ;end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);begin Application.Minimize ; CanClose := CanExit ;end;procedure TForm1.Button1Click(Sender: TObject);begin CanExit := True ;end;end. procedure MyMesgPro(var meg:TMessage);message WM_SYSCOMMAND;截取这个消息。如果是最小化和关闭消息写自己的代码,否则inherited; unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, shellapi, AppEvnts, Menus;const WMtask=WM_USER+102;type TForm1 = class(TForm) Button1: TButton; ApplicationEvents1: TApplicationEvents; PopupMenu1: TPopupMenu; N1: TMenuItem; Button2: TButton; Button3: TButton; Button4: TButton; Button5: TButton; Button6: TButton; Button7: TButton; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure ApplicationEvents1Activate(Sender: TObject); procedure ApplicationEvents1Minimize(Sender: TObject); procedure ApplicationEvents1Restore(Sender: TObject); procedure N1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); private { Private declarations } lpData:NotifyIconData; public { Public declarations } procedure MyPro(var msg:TWMSYSCOMMAND);message WM_SYSCOMMAND; procedure TaskPro(var msg:TMessage);message WMtask; procedure InitNotifyData; procedure AddNotifyIcon(const uID:UINT;icon:Hicon); procedure DeleteNotifyIcon(const uID:UINT); procedure ChangeNotifyIcon(const uID:UINT;icon:Hicon); end;var Form1: TForm1;implementation{$R *.dfm}{$R project1.res}PROCEDURE tfORM1.MyPro(var msg:TWMSYSCOMMAND);begin if (msg.CmdType and $FFF0 = SC_CLOSE) then begin application.Minimize; exit; end; if (msg.CmdType and $FFF0 = SC_MINIMIZE) then begin application.Minimize; exit; end; inherited;end;procedure TForm1.FormShow(Sender: TObject);var Owner : HWnd;begin Owner:=GetWindow(Handle,GW_OWNER); ShowWindow(Owner,SW_HIDE);end;Procedure TForm1.InitNotifyData;begin lpData.Wnd:=form1.Handle;// lpdata.uID:=111; lpdata.szTip:='我的托盘程序'; lpdata.uFlags:=7; lpdata.uCallbackMessage:=WMtask; lpdata.hIcon:=loadicon(hInstance,'MAINICON'); lpdata.cbSize:=sizeof(NotifyIcondata);end;procedure TForm1.AddNotifyIcon(const uID:UINT;icon:Hicon);begin lpdata.uID:=uID; lpdata.hIcon:=icon; Shell_NotifyIcon(NIM_ADD,@lpData);end;procedure TForm1.DeleteNotifyIcon(const uID:UINT);begin lpdata.uID:=uID; Shell_NotifyIcon(NIM_DELETE,@lpdata);end;procedure TForm1.ChangeNotifyIcon(const uID:UINT;icon:HIcon);begin lpdata.uID:=uID; lpdata.hIcon:=icon; shell_notifyicon(NIM_MODIFY,@lpdata);end;procedure Tform1.TaskPro(var msg:TMessage);var lp:TPoint;begin case msg.LParam of WM_LBUTTONDOWN: begin application.Restore; application.BringToFront; end; WM_RBUTTONDOWN: begin getcursorpos(lp); form1.PopupMenu1.Popup(lp.X,lp.Y); end; WM_MBUTTONDOWN:; WM_LBUTTONUP:; WM_RBUTTONUP:; WM_MBUTTONUP:; WM_MOUSEMOVE:; WM_LBUTTONDBLCLK:; WM_RBUTTONDBLCLK:; WM_MBUTTONDBLCLK:; end;end;procedure TForm1.Button1Click(Sender: TObject);begin application.Terminate;end;procedure TForm1.ApplicationEvents1Activate(Sender: TObject);var Owner : HWnd;begin Owner:=GetWindow(Handle,GW_OWNER); ShowWindow(Owner,SW_HIDE);end;procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);var Owner : HWnd;begin Owner:=GetWindow(Handle,GW_OWNER); ShowWindow(Owner,SW_HIDE);end;procedure TForm1.ApplicationEvents1Restore(Sender: TObject);var Owner : HWnd;begin Owner:=GetWindow(Handle,GW_OWNER); ShowWindow(Owner,SW_HIDE);end;procedure TForm1.N1Click(Sender: TObject);begin application.Terminate;end;procedure TForm1.Button2Click(Sender: TObject);begin form1.AddNotifyIcon(555,loadicon(hinstance,'key'));end;procedure TForm1.Button3Click(Sender: TObject);begin form1.AddNotifyIcon(556,loadicon(hinstance,'mainicon'));end;procedure TForm1.FormCreate(Sender: TObject);begin form1.InitNotifyData;end;procedure TForm1.Button4Click(Sender: TObject);begin form1.DeleteNotifyIcon(555);end;procedure TForm1.Button5Click(Sender: TObject);begin form1.DeleteNotifyIcon(556);end;procedure TForm1.Button6Click(Sender: TObject);begin form1.ChangeNotifyIcon(555,loadicon(hinstance,'friendship'));end;end. string转移到数组里,基础问题却这么难解决? 电子台秤用232接口接串口 有关字体大小的问题,谁能帮我解决一下,谢谢? 帮忙一下,分快用完了,delphi+MSSQL,怎样用SQL语句算出下面的值? 关于MessageBox的菜鸟级问题,在线等,解决后马上结贴 who有tms的开发文档? 关于网络数据库问题请教200分相送 谁能告诉我按窗口的最小化按钮应该扑获那个消息 请大家帮个忙 如何用query控件清空已经打开的DBF库? 求助!!!怎么打开这种类型的文件 ".eml"?? 如何动态设置ADO访问ACCESS数据库(在线等候)
TYourMainForm = class(TForm)
private FNotifyIconData : TNotifyIconData;
public
procedure InitNotifyData;
procedure AddNotifyIcon;
procedure DeleteNotifyIcon;
procedure ChangeNotifyIcon;
end;procedure TF_AutoBackMain.InitNotifyData;
var
FIcon: TIcon;
begin
FIcon:= TIcon.Create;
ImageList2.GetIcon(0,FIcon);
with FNotifyIconData do
begin
cbSize := SizeOf(FNotifyIconData);
Wnd := Handle;
uID := 199999;
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
uCallbackMessage := WM_USERNOTIFY;
hIcon := FIcon.Handle;
lstrcpy(szTip, PChar(rsTip));
// szTip := rsTip;
end;
end;
procedure TF_AutoBackMain.AddNotifyIcon;
begin
Shell_NotifyIcon(NIM_ADD,@FNotifyIconData);
end;
procedure TF_AutoBackMain.ChangeNotifyIcon;
begin
Shell_NotifyIcon(NIM_MODIFY,@FNotifyIconData);
end;procedure TF_AutoBackMain.DeleteNotifyIcon;
begin
Shell_NotifyIcon(NIM_DELETE,@FNotifyIconData);
end;
procedure TF_AutoBackMain.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
case FCloseChioce of
ccClose:
begin
Action := caFree;
end;
ccHide:
begin
Action:= caNone;
Hide;
AddNotifyIcon;
end;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
CanExit : Boolean ;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
CanExit := False ;
end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
Application.Minimize ;
CanClose := CanExit ;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
CanExit := True ;
end;end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, shellapi, AppEvnts, Menus;const WMtask=WM_USER+102;type
TForm1 = class(TForm)
Button1: TButton;
ApplicationEvents1: TApplicationEvents;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure ApplicationEvents1Activate(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
lpData:NotifyIconData;
public
{ Public declarations }
procedure MyPro(var msg:TWMSYSCOMMAND);message WM_SYSCOMMAND;
procedure TaskPro(var msg:TMessage);message WMtask;
procedure InitNotifyData;
procedure AddNotifyIcon(const uID:UINT;icon:Hicon);
procedure DeleteNotifyIcon(const uID:UINT);
procedure ChangeNotifyIcon(const uID:UINT;icon:Hicon);
end;var
Form1: TForm1;implementation{$R *.dfm}
{$R project1.res}PROCEDURE tfORM1.MyPro(var msg:TWMSYSCOMMAND);
begin
if (msg.CmdType and $FFF0 = SC_CLOSE) then
begin
application.Minimize;
exit;
end;
if (msg.CmdType and $FFF0 = SC_MINIMIZE) then
begin
application.Minimize;
exit;
end;
inherited;
end;procedure TForm1.FormShow(Sender: TObject);
var Owner : HWnd;
begin
Owner:=GetWindow(Handle,GW_OWNER);
ShowWindow(Owner,SW_HIDE);
end;Procedure TForm1.InitNotifyData;
begin
lpData.Wnd:=form1.Handle;
// lpdata.uID:=111;
lpdata.szTip:='我的托盘程序';
lpdata.uFlags:=7;
lpdata.uCallbackMessage:=WMtask;
lpdata.hIcon:=loadicon(hInstance,'MAINICON');
lpdata.cbSize:=sizeof(NotifyIcondata);
end;procedure TForm1.AddNotifyIcon(const uID:UINT;icon:Hicon);
begin
lpdata.uID:=uID;
lpdata.hIcon:=icon;
Shell_NotifyIcon(NIM_ADD,@lpData);
end;procedure TForm1.DeleteNotifyIcon(const uID:UINT);
begin
lpdata.uID:=uID;
Shell_NotifyIcon(NIM_DELETE,@lpdata);
end;procedure TForm1.ChangeNotifyIcon(const uID:UINT;icon:HIcon);
begin
lpdata.uID:=uID;
lpdata.hIcon:=icon;
shell_notifyicon(NIM_MODIFY,@lpdata);
end;procedure Tform1.TaskPro(var msg:TMessage);
var lp:TPoint;
begin
case msg.LParam of
WM_LBUTTONDOWN:
begin
application.Restore;
application.BringToFront;
end;
WM_RBUTTONDOWN:
begin
getcursorpos(lp);
form1.PopupMenu1.Popup(lp.X,lp.Y);
end;
WM_MBUTTONDOWN:;
WM_LBUTTONUP:;
WM_RBUTTONUP:;
WM_MBUTTONUP:;
WM_MOUSEMOVE:;
WM_LBUTTONDBLCLK:;
WM_RBUTTONDBLCLK:;
WM_MBUTTONDBLCLK:;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
application.Terminate;
end;procedure TForm1.ApplicationEvents1Activate(Sender: TObject);
var Owner : HWnd;
begin
Owner:=GetWindow(Handle,GW_OWNER);
ShowWindow(Owner,SW_HIDE);
end;procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
var Owner : HWnd;
begin
Owner:=GetWindow(Handle,GW_OWNER);
ShowWindow(Owner,SW_HIDE);
end;procedure TForm1.ApplicationEvents1Restore(Sender: TObject);
var Owner : HWnd;
begin
Owner:=GetWindow(Handle,GW_OWNER);
ShowWindow(Owner,SW_HIDE);
end;procedure TForm1.N1Click(Sender: TObject);
begin
application.Terminate;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
form1.AddNotifyIcon(555,loadicon(hinstance,'key'));
end;procedure TForm1.Button3Click(Sender: TObject);
begin
form1.AddNotifyIcon(556,loadicon(hinstance,'mainicon'));
end;procedure TForm1.FormCreate(Sender: TObject);
begin
form1.InitNotifyData;
end;procedure TForm1.Button4Click(Sender: TObject);
begin
form1.DeleteNotifyIcon(555);
end;procedure TForm1.Button5Click(Sender: TObject);
begin
form1.DeleteNotifyIcon(556);
end;procedure TForm1.Button6Click(Sender: TObject);
begin
form1.ChangeNotifyIcon(555,loadicon(hinstance,'friendship'));
end;end.