解决方案 »
- ACReport中国式报表控件2010版(含文档和demo)
- delphi 如何将dbgrid隐藏的列不导出
- 再次咨询TDBChart问题
- CoolTrayIcon v4.4.0这个组件我不怎么会用嘛!
- 请问怎么让一个Form成为一个带ICON的窗口?也就是在状态条上和程序的主窗口并列的图标?
- 请教进制转换
- ADOConnection的ConnectionTimeout不起作用?
- Chart控件背景动态添加?
- edit4.text:=im.oicture.bitmap.pixelformat;时应该用什么函数转换pixelformat为string类型啊?
- 开发平台(已做成虚拟机系统)
- 为什么我的状态区图标处理不了鼠标消息?
- 使用串口通信出现的问题!急!
MY_MESSAGE = WM_USER + 78; //托盘图标返回消息
MM_SHOW = WM_USER + 199; //托盘图标返回消息 private
Fnid : PNotifyIconDataA;
New(Fnid);
with Fnid^ do
begin
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Application.Icon.Handle;
uCallbackMessage := MY_MESSAGE;
StrPCopy(szTip,Application.Title);
szTip :='讯鲨VPN';
end;
Shell_NotifyIcon(NIM_ADD, Fnid);
//注册任务栏图标。
Application.OnMinimize:=OnMinimize;退出程序时要记得释放
Shell_NotifyIcon(NIM_DELETE, Fnid);
http://www.winu.cn/thread-1666-1-1.html
1、设置RXTrayIcon的icon和icons
2、给popupmenu关联一个右键菜单
3、在它的onDblClick事件中写一下代码
procedure TFormMain.RxTrayIcon1DblClick(Sender: TObject);
begin
ShowWindow(Application.Handle, SW_RESTORE);
setwindowpos(application.handle,HWND_TOPMOST,0,0,0,0,swp_hidewindow);
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellAPI, ImgList, Menus; const WM_NOTIFY = WM_USER + 101; // TRAY消息
WM_TOOLTRAYICON = WM_USER+1;
type
TfrmMain = class(TForm)
imlToolbar: TImageList;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
procedure OnAppMinimize(Sender: TObject); // 应用程序最小化响应函数
procedure OnNotify(var Msg : TMessage); message WM_NOTIFY;
procedure ToolMSG(var Msg: TWMSYSCOMMAND); Message WM_TOOLTRAYICON;
public
{ Public declarations }
end; var
frmMain: TfrmMain;
NotifyIcon : TNotifyIconData; implementation {$R *.dfm} procedure TfrmMain.FormCreate(Sender: TObject);
var
Icon : TIcon;
begin //
//NotifyIcon为全局变量,在程序的开头已经定义了
//
with NotifyIcon do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle; //指向当前窗体frmMain的句柄
uID:=1;
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage:=WM_NOTIFY;
hIcon:=Application.Icon.Handle;
icon := TIcon.Create();
frmmain.imlToolbar.GetIcon(0, icon);
hIcon := icon.Handle;
szTip:= '短信程序 ';
end;
Application.OnMinimize := OnAppMinimize;
end; //
// 应用程序最小化时调用此函数
//
procedure TfrmMain.OnAppMinimize(Sender: TObject);
begin
// if Config.m_Config.m_Hide then
// begin
frmMain.Visible := False;
//
// 把设置好的变量NotifyIcon加入到系统中以便处理
//
Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
// end;
end; //
// 托盘图标响应事件
//
procedure TfrmMain.OnNotify(var Msg: TMessage);
var
pos : TPoint;
begin
case Msg.LParam of
WM_LBUTTONDBLCLK: // 双击事件
begin
frmMain.Visible := True ;
Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);
Application.Restore();
SetForegroundWindow(frmMain.Handle);
end;
WM_RBUTTONUP: // 右键点击
begin
GetCursorPos(pos);
frmMain.PopupMenu1.Popup(pos.X, pos.Y);
end;
End;
end; procedure TfrmMain.N1Click(Sender: TObject);
begin
close;
end; procedure TfrmMain.ToolMSG(var Msg: TWMSYSCOMMAND);
begin
if (Msg.Msg = WM_TOOLTRAYICON) and
(Msg.Key = WM_LBUTTONDBLCLK) then
showwindow(application.handle,sw_show);
end; end.
http://www.tomore.com/2/2083.html 下载地址4条裤衩就看你的啦
//运行后在托盘出现图标,在图标有右键菜单,可以显示,最小化,退出程序。
unit main;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ShellAPI, StdCtrls, Menus;
const
WM_MYTRAYICONCALLBACK = WM_USER + 1000;type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
MyTrayIcon: TNotifyIconData;
procedure WMMyTrayIconCallback (var Msg: TMessage); message WM_MYTRAYICONCALLBACK; public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.N1Click(Sender: TObject);
begin
Self.Visible := True;
Application.ShowMainForm := Visible;end;procedure TForm1.N2Click(Sender: TObject);
begin
Self.Visible := False;
Application.ShowMainForm := Visible;end;procedure TForm1.N3Click(Sender: TObject);
begin
Application.Terminate;end;procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);
end;procedure TForm1.WMMyTrayIconCallback(var Msg: TMessage);
var
pPos: TPoint;
begin
case Msg.LParam of
WM_LBUTTONDBLCLK:
begin
Visible := not Visible;
Application.ShowMainForm := Visible;
SetForegroundWindow(Application.Handle);
end;
WM_RBUTTONDOWN:
begin
GetCursorPos(pPos);
PopupMenu1.Popup(pPos.x,pPos.y);
end;
end;end;procedure TForm1.FormCreate(Sender: TObject);
begin
Inherited;
Self.Visible := False;
Application.ShowMainForm := Visible;
{ 创建Tray }
with MyTrayIcon do
begin
cbSize := SizeOf(TNotifyIconData); { 记录TNotifyIconDataA的大小 }
Wnd := Self.Handle; { 接收Tray小图标区鼠标事件的窗口的句柄 }
uID := 1; { 图标的ID(Tray小图标区鼠标事件的wPara参数的值)}
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; { 此条消息的有效范围(低三位有效)
NIF_MESSAGE 0x1: uCallbackMessage参数有效
NIF_ICON 0x2: hIcon is valid参数有效
NIF_TIP 0x4: szTip is valid参数有效 }
uCallbackMessage := WM_MYTRAYICONCALLBACK; { 系统回送消息的ID }
hIcon := Application.Icon.Handle; { 显示在Tray小图标区上的图标的句柄 }
szTip := '托盘'; { 鼠标移动到图标上时系统显示的提示信息 }
end;
Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);end;end.
这地址下不到啦
谁提供下 网上找了N久 都不能下了 我是D7的 谁能发给我
[email protected]