托盘程序总是不能编译通过
delphi吧
全部回复
仅看楼主
level 7
hxr225976 楼主
我按照这个例程进行编写,网址为:http://blog.163.com/maentao_1014/blog/static/326310320088423637101/,结果总是不能编译,对于的代码为:
cbSize:=SizeOf(TNotifyIconData);
错误信息如下:
[DCC Error] Unit1.pas(41): E2034 Too many actual parameters
[DCC Error] Unit1.pas(41): E2029 '(' expected but ')' found
[DCC Error] Unit1.pas(42): E2029 ')' expected but identifier 'Wnd' found
[DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
用的版本是XE2,请大神指点!
2013年11月07日 09点11分 1
吧务
level 14
要不你装个翻译软件?
2013年11月07日 14点11分 2
level 7
感觉像符号输入的时候输的不对,
2013年11月08日 04点11分 3
就是这句报错 cbSize:=SizeOf(TNotifyIconData); 偶是看不懂了!
2013年11月08日 05点11分
回复 hxr225976 :第一句话是太多实参, with Phone_ico do begin cbSize :=sizeof(Phone_ico); Wnd := self.Handle; uID := ID; uFlags := nif_Icon or nif_Message or nif_Tip; uCallbackMessage := MI_ICONEVEN; hIcon := PhoneIcon.Handle; szTip := '电话助手'; end;
2013年11月08日 05点11分
level 13
话说现在都自带有TTrayIcon控件了,还用得着去写那么一堆代码?
2013年11月08日 05点11分 4
额、、惊恐莫名!新版本这么牛? [惊讶]
2013年11月08日 05点11分
回复 hxr225976 :自带这控件都已经存在N年了。
2013年11月08日 05点11分
level 7
我估计是你的分号有问题,
不是英语输入方式下的“;”
2013年11月08日 05点11分 5
level 7
我到时编过托盘程序,我去找找,找到了再贴出来。
2013年11月09日 03点11分 6
level 7
首先定义一个用户自定义的消息const WM_NID=WM_USER+1000;
然后添加
public
{ Public declarations }
icondata:TNotifyIconData;
然后就是你自己在某个过程或者函数中写实现托盘的代码了
with icondata do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle; //指向当前窗体Form1的句柄
uID:=1;
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage:=WM_NID;
hIcon:=Application.Icon.Handle;
szTip:='OOPTest';
end;
//以应用程序的标题做为图标的提示
strpcopy(icondata.sztip,application.title);
//向托盘中添加图标
shell_notifyicon(NIM_ADD,@icondata);
//...
代码大体上是没有什么问题的,可能的原因你是否是直接在网页的页面把人家的代码直接复制过去的,然后就是begin后面到cbSize之间的空格删除一边。还是有问题的话就慢慢找,别急!
2013年11月09日 06点11分 7
@OOPhappy @顶之座__赫卡特 这段代码我还是不怎么玩的转,请用TTrayIcon控件帮忙写一个例程呗!
2013年11月10日 05点11分
回复 hxr225976 :自己看帮助文档,或网上搜索一下“delphi ttrayicon”。
2013年11月10日 06点11分
level 7
代码如下,比较简单就是向托盘添加了一个Delphi7的图标
unit UnitNotidy;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,shellapi;
//要添加Shellapi引用
const WM_NID=WM_USER+1000;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
icondata:TNotifyIconData;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
with icondata do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle; //指向当前窗体Form1的句柄
uID:=1;
uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
uCallBackMessage:=WM_NID;
hIcon:=Application.Icon.Handle;
szTip:='OOPTest';
end;
//以应用程序的标题做为图标的提示
strpcopy(icondata.sztip,application.title);
//向托盘中添加图标
shell_notifyicon(NIM_ADD,@icondata);
//...
end;
end.
//代码运行图
2013年11月10日 05点11分 8
level 1
把with do 去掉 写完整代码就OK了。。xe5 编译通过
2014年01月17日 05点01分 9
level 11
错误提示1.过多的参数
2.括号不匹配
3.是也是括号问题
2014年01月20日 03点01分 10
level 1
这个是XE升级的问题。
取得size, 得换成下面的写法。
cbSize:=TNotifyIconDataA.SizeOf;
别的不用动。
2014年03月03日 13点03分 12
1