我按照csdn上面一位大哥的文章写了一个托盘的东东,可他对我说message这错,我注释掉以后,不报错了可怎么对着托盘点右键就是没反应啊,请大家帮帮忙,代码如下,现在是没注释的,就报错。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellAPI, StdCtrls, Menus;
const WM_NID=WM_USER+1000;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
NotifyIcon:TNotifyIconData;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
//NotifyIcon为全局变量,在程序的开头已经定义了
with NotifyIcon 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:='张家恶少';
end;
//把设置好的变量NotifyIcon加入到系统中以便处理
Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
end;procedure WMNID(var msg:TMessage);Message WM_NID;
begin
case msg.LParam of
WM_LBUTTONUp:Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP:ShowMessage('您点击的是右键');
End;
End;procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);
end;end.我在type里面声明以后,他就会说不存在TForm1.WMNID,请帮忙,并告诉我一下,问题出在哪里,我想搞明白,谢谢了
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellAPI, StdCtrls, Menus;
const WM_NID=WM_USER+1000;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
NotifyIcon:TNotifyIconData;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
//NotifyIcon为全局变量,在程序的开头已经定义了
with NotifyIcon 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:='张家恶少';
end;
//把设置好的变量NotifyIcon加入到系统中以便处理
Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
end;procedure WMNID(var msg:TMessage);Message WM_NID;
begin
case msg.LParam of
WM_LBUTTONUp:Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP:ShowMessage('您点击的是右键');
End;
End;procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);
end;end.我在type里面声明以后,他就会说不存在TForm1.WMNID,请帮忙,并告诉我一下,问题出在哪里,我想搞明白,谢谢了
解决方案 »
- 【散分】你们用Delphi做哪方面开发啊?
- 将Word文档以BlobFiled形式存进数据库中,如何读取出来保存?
- demo里面的例子在哪里?
- MDI窗体显示问题
- 用BDE连接加密的PARADOX数据库,已经去处LOGINprompt,但是打开表时,还是提示输入密码?具体设置如下??
- 关于合并单元格的问题,急
- 如何判断客户端已连接上远程服务器?(在线等待)
- 请问哪里有windows xp 的控件下载?
- 关于delphi6中的Demos\Corba\Idl2Pas\Midas XML例子
- OnKeyDown/OnKeyPress的一个问题
- 怎么取得桌面的图象
- Delphi中能用ADODB.Connection/ADODB.RecordSet吗?
procedure tform1.WMNID(var msg:TMessage);Message WM_NID;
begin
case msg.LParam of
WM_LBUTTONUp:Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP:ShowMessage('您点击的是右键');
End;
End;应该没问题了;
然后再实现部分写入
procedure tform1.WMNID(var msg:TMessage);Message WM_NID;
begin
case msg.LParam of
WM_LBUTTONUp:Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP:ShowMessage('您点击的是右键');
End;
End;
[Error] Unit1.pas(56): Object or class type required
[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
还是抱错,以上是报错信息
56行是:case msg.LParam of
不过我把53行的Message WM_NID去掉了他还是一样的错误啊
另外我想问一下,如果我要让她右击托盘的时候出来的不是框而是那种小的菜单是怎么弄的呢?能把代码写一下吗?谢谢了,收到了我就结帖
在此谢谢大家的解答。