简单问题,比较急!! 怎样实现在按下最小化按钮的时候程序不是显示在任务拦上,而是象QQ那样显示在时钟那边的一拦上。然后再点击的时候会出现菜单象退出、还原什么的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议你去搜索一下,系统托盘程序。其中创建,修改,删除系统托盘图标只需要调用windows的api函数 Shell_NotifyIcon即可! 用Shell_NotifyIcon()这个API或者自己去找现成的控件 下面这个是我当年写的,我刚才运行了一下,还可以用,你看看吧unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI, StdCtrls, Menus, AppEvnts;const WM_TrayMessage=WM_User+100;type TForm1 = class(TForm) CheckBox1: TCheckBox; PopupMenu1: TPopupMenu; Hello1: TMenuItem; World1: TMenuItem; procedure CheckBox1Click(Sender: TObject); procedure Hello1Click(Sender: TObject); procedure World1Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private NID: TNotifyIconData; { Private declarations } public procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage; //建立wm_traymessage的映射。 //声明是traymessage,只要tray有message,那么就会执行wmtraymessage procedure wmsyscommand(var Msg:TWMSysCommand); message WM_SYSCOMMAND; //托盘图标的返回消息 end;var Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.WMTrayMessage(var msg: TMessage);var p:TPoint;begin if (Msg.LParam=WM_LBUTTONDBLCLK) then begin MessageDlg('您在任务栏图标上按双击左键', mtInformation, [mbOK], 0); end; if msg.LParam=WM_RButtonDown then begin GetCursorPos(p); //取光标位置 PopupMenu1.Popup(p.x,p.y); //弹出菜单 end; if (msg.LParam=WM_LButtonDown) and Form1.Enabled then begin Form1.Visible:=not Form1.Visible;// Shell_NotifyIcon(NIM_DELETE,@NID); end;end;procedure TForm1.CheckBox1Click(Sender: TObject);begin if CheckBox1.Checked then Shell_NotifyIcon(NIM_ADD,@NID) else Shell_NotifyIcon(NIM_DELETE,@NID); {Shell_NotifyIcon是tray区编程函数,它只有两个参数 第一个参数可为:nim_add :向tray区增加一个图标 nim_delete:删除tray区一个图标 nim_modify:修改tray区一个图标 第二个参数包含的信息可以用于系统对任务tray区的处理 }end;procedure TForm1.Hello1Click(Sender: TObject);begin MessageDlg('Hello!', mtInformation, [mbOK], 0);end;procedure TForm1.World1Click(Sender: TObject);begin MessageDlg('World!', mtInformation, [mbOK], 0);end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin CheckBox1.Checked := False;end;procedure TForm1.wmsyscommand(var Msg: TWMSysCommand);begin if (Msg.CmdType=SC_MINIMIZE) or (Form1.Enabled=false) THEN begin Shell_NotifyIcon(NIM_ADD,@NID); Form1.Hide; end else INHERITED; //如果消息是mimimize,就处理消息,否则,让它继续传下去。end;procedure TForm1.FormCreate(Sender: TObject);begin NID.cbSize:=SizeOf(TNotifyIconData); NID.hIcon:=Application.Icon.Handle; NID.szTip:= '欢迎使用任务栏图标'; NID.uCallbackMessage:=WM_TrayMessage; NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP; {uflags描述那些项有效 nif_icon:hicon有效 nif_message:ucallbackmessage有效 nif_tip:tip有效} NID.uID:=0;//uID域是程序员定义的一个唯一标识符。如果一个应用程序有多个托盘图标,则每个图标需要有唯一的I D NID.Wnd:=Handle;{tray区返回消息的对象,这些消息将用户对tray区图标的操作通知给程序}end;procedure TForm1.FormDestroy(Sender: TObject);begin Shell_NotifyIcon(NIM_DELETE,@NID);end;end. 多线程 delphi 怎样把增、删、改、查例子功能封装一个单元或模块里。 代码创建表问题 今天升星了,高兴,散分。不过身体不太好,哎。 怎样在程序创建时打开多个窗体? 我的d5下的程序用到system单元下的VarArrayCreate函数,在d7下不支持 3个小问题 急急急急急急急急急急急急急急急急急急急急急急! 如何禁止修改某一字段的值? delphi下怎样把一个主机名转换成ip地址,谢谢帮忙 初学者的问题 还是上下位机用gprs通信问题
其中创建,修改,删除系统托盘图标只需要调用windows的api函数 Shell_NotifyIcon即可!
或者自己去找现成的控件
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, StdCtrls, Menus, AppEvnts;const
WM_TrayMessage=WM_User+100;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
PopupMenu1: TPopupMenu;
Hello1: TMenuItem;
World1: TMenuItem;
procedure CheckBox1Click(Sender: TObject);
procedure Hello1Click(Sender: TObject);
procedure World1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
NID: TNotifyIconData;
{ Private declarations }
public
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
//建立wm_traymessage的映射。
//声明是traymessage,只要tray有message,那么就会执行wmtraymessage
procedure wmsyscommand(var Msg:TWMSysCommand); message WM_SYSCOMMAND;
//托盘图标的返回消息 end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.WMTrayMessage(var msg: TMessage);
var
p:TPoint;
begin
if (Msg.LParam=WM_LBUTTONDBLCLK) then
begin
MessageDlg('您在任务栏图标上按双击左键', mtInformation, [mbOK], 0);
end;
if msg.LParam=WM_RButtonDown then
begin
GetCursorPos(p); //取光标位置
PopupMenu1.Popup(p.x,p.y); //弹出菜单
end;
if (msg.LParam=WM_LButtonDown) and Form1.Enabled then
begin
Form1.Visible:=not Form1.Visible;
// Shell_NotifyIcon(NIM_DELETE,@NID);
end;
end;procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then Shell_NotifyIcon(NIM_ADD,@NID) else Shell_NotifyIcon(NIM_DELETE,@NID);
{Shell_NotifyIcon是tray区编程函数,它只有两个参数
第一个参数可为:nim_add :向tray区增加一个图标
nim_delete:删除tray区一个图标
nim_modify:修改tray区一个图标
第二个参数包含的信息可以用于系统对任务tray区的处理
}
end;procedure TForm1.Hello1Click(Sender: TObject);
begin
MessageDlg('Hello!', mtInformation, [mbOK], 0);
end;procedure TForm1.World1Click(Sender: TObject);
begin
MessageDlg('World!', mtInformation, [mbOK], 0);
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CheckBox1.Checked := False;
end;procedure TForm1.wmsyscommand(var Msg: TWMSysCommand);
begin
if (Msg.CmdType=SC_MINIMIZE) or (Form1.Enabled=false) THEN
begin
Shell_NotifyIcon(NIM_ADD,@NID);
Form1.Hide;
end
else
INHERITED;
//如果消息是mimimize,就处理消息,否则,让它继续传下去。
end;procedure TForm1.FormCreate(Sender: TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= '欢迎使用任务栏图标';
NID.uCallbackMessage:=WM_TrayMessage;
NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
{uflags描述那些项有效
nif_icon:hicon有效
nif_message:ucallbackmessage有效
nif_tip:tip有效}
NID.uID:=0;
//uID域是程序员定义的一个唯一标识符。如果一个应用程序有多个托盘图标,则每个图标需要有唯一的I D
NID.Wnd:=Handle;{tray区返回消息的对象,这些消息将用户对tray区图标的操作通知给程序}
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NID);
end;end.