关于message消息 我定义了一个过程procedure WMNID(var msg:TMessage); message WM_NID; 编译的时候说,Unknown directive: 'message',请问这个是什么问题?WM_NID 我已经定义了 const WM_NID=WM_USER+1000; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将const WM_NID=WM_USER+1000;放在procedure WMNID(var msg:TMessage); message WM_NID;的前面 我是把const WM_NID=WM_USER+1000;放在procedure WMNID(var msg:TMessage); message WM_NID;的前面可是报错 呵呵。。肯定是单元文件中没有增加对 Messages的引用。 有把messages加到uses里面的。还是报错。名字换了也一样郁闷啊 在其上面Ctrl+Shift+c,生成其代码框架;随便输入些东西进去再编译看还会不会 你这种代码应该没有问题不过你有没有在procedure form1.WMNID(var msg:TMessage); message WM_NID;里写东西啊 写了呀。我把我的源码贴出来。大家帮忙看看吧unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, shellapi; const WM_NID=WM_USER+1000;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end;procedure WMNID(var msg:TMessage); message WM_NID; //这里message报错var Form1: TForm1; Extendedstyle:integer; NotifyIcon:TNotifyIconData;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);beginExtendedstyle := GetWindowLong (Application.Handle, GWL_EXstyle);SetWindowLong(Application.Handle, GWL_EXstyle, Extendedstyle OR WS_EX_TOOLWINDOWAND NOT WS_EX_APPWINDOW); //用于隐藏任务栏上的程序 With NotifyIcon do begin cbSize:=SizeOf(TNotifyIconData); Wnd:=Handle; uID:=1; uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier uCallBackMessage:=WM_NID; hIcon:=Application.Icon.Handle; szTip:='我是老大'; end; Shell_NotifyIcon(NIM_ADD,@NotifyIcon);end;procedure WMNID(var msg:TMessage); message WM_NID; //这里的message也有问题begin case msg.LParam of WM_LBUTTONUp: Form1.Visible:=not Form1.Visible; WM_RBUTTONUP: ShowMessage('right'); End;End;procedure TForm1.FormDestroy(Sender: TObject);begin Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);end;end. private { Private declarations } NotifyIcon: TNotifyIconData; procedure IconOnClick(var Msg: TMessage); message WM_NID;//把它放在private声明中去,再试试看 明显错误,既然要注册成窗口的消息,就一定要把过程放到窗体里下面为修改过的的代码:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, shellapi; const WM_NID=WM_USER+1000;type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public procedure WMNID(var msg:TMessage); message WM_NID; //这里message报错 { Public declarations } end;var Form1: TForm1; Extendedstyle:integer; NotifyIcon:TNotifyIconData;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);beginExtendedstyle := GetWindowLong (Application.Handle, GWL_EXstyle);SetWindowLong(Application.Handle, GWL_EXstyle, Extendedstyle OR WS_EX_TOOLWINDOWAND NOT WS_EX_APPWINDOW); //用于隐藏任务栏上的程序 With NotifyIcon do begin cbSize:=SizeOf(TNotifyIconData); Wnd:=Handle; uID:=1; uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier uCallBackMessage:=WM_NID; hIcon:=Application.Icon.Handle; szTip:='我是老大'; end; Shell_NotifyIcon(NIM_ADD,@NotifyIcon);end;procedure TForm1.WMNID(var msg:TMessage); message WM_NID; //这里的message也有问题begin case msg.LParam of WM_LBUTTONUp: Form1.Visible:=not Form1.Visible; WM_RBUTTONUP: ShowMessage('right'); End;End;procedure TForm1.FormDestroy(Sender: TObject);begin Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);end;end. 哦了procedure TForm1.WMNID(var msg:TMessage); message WM_NID; //这里的message也有问你现在是实现函数,后面不用跟消息了。改成procedure TForm1.WMNID(var msg:TMessage);至于其他的。 uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier去看看他们是哪个单元定义的常量,引用那个单元了。。我忘记了! 建议养成函数声明完成后用Ctrl+Shift+c 完成框架功能,免的在这些小问题是纠缠! 谢谢各位帮助,问题已经解决了。我把procedure WMNID(var msg:TMessage); message WM_NID; 放到 public 里WMNID过程中的message WM_NID;去掉就可以通过了。至于那个uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP;我很是纳闷。代码重新复制粘贴一遍就没有错了。真是奇怪。 怎样让sql语句某列进行分组合计 带@的函数是什么作用,怎么定义啊? 使用delphi 7的image控件来打印,但是打印时想让image控件旋转90度??高手指教 编译时出错一个文件没有找到 请大家进来帮个忙!谢谢了! edit没有属性可以设置只能输入数字吗?vc都有的阿。 自动升级的问题 如何用delphi编机器启动时让程序自动加载运行 Delphi程序,在xp下打印不出来的问题怎么解决? 求个能导入excel各版本的组件或方法. 大家用什么去兼容的? 如何隐藏程序,就是任务栏上没有程序,系统右下角的托盘上有显示程序图标 ASP中调用DELPHI封装的richedit组件
const WM_NID=WM_USER+1000;
放在
procedure WMNID(var msg:TMessage); message WM_NID;
的前面
const WM_NID=WM_USER+1000;
放在
procedure WMNID(var msg:TMessage); message WM_NID;
的前面
可是报错
还是报错。
名字换了也一样
郁闷啊
里写东西啊
我把我的源码贴出来。
大家帮忙看看吧unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, shellapi;
const WM_NID=WM_USER+1000;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure WMNID(var msg:TMessage); message WM_NID; //这里message报错
var
Form1: TForm1;
Extendedstyle:integer;
NotifyIcon:TNotifyIconData;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Extendedstyle := GetWindowLong (Application.Handle, GWL_EXstyle);
SetWindowLong(Application.Handle, GWL_EXstyle, Extendedstyle OR WS_EX_TOOLWINDOW
AND NOT WS_EX_APPWINDOW); //用于隐藏任务栏上的程序 With NotifyIcon do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle;
uID:=1;
uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier
uCallBackMessage:=WM_NID;
hIcon:=Application.Icon.Handle;
szTip:='我是老大';
end;
Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
end;procedure WMNID(var msg:TMessage); message WM_NID; //这里的message也有问题
begin
case msg.LParam of
WM_LBUTTONUp: Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP: ShowMessage('right');
End;
End;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);
end;end.
{ Private declarations }
NotifyIcon: TNotifyIconData;
procedure IconOnClick(var Msg: TMessage); message WM_NID;
//把它放在private声明中去,再试试看
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, shellapi;
const WM_NID=WM_USER+1000;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
procedure WMNID(var msg:TMessage); message WM_NID; //这里message报错
{ Public declarations }
end;
var
Form1: TForm1;
Extendedstyle:integer;
NotifyIcon:TNotifyIconData;
implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
Extendedstyle := GetWindowLong (Application.Handle, GWL_EXstyle);
SetWindowLong(Application.Handle, GWL_EXstyle, Extendedstyle OR WS_EX_TOOLWINDOW
AND NOT WS_EX_APPWINDOW); //用于隐藏任务栏上的程序 With NotifyIcon do
begin
cbSize:=SizeOf(TNotifyIconData);
Wnd:=Handle;
uID:=1;
uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier
uCallBackMessage:=WM_NID;
hIcon:=Application.Icon.Handle;
szTip:='我是老大';
end;
Shell_NotifyIcon(NIM_ADD,@NotifyIcon);
end;procedure TForm1.WMNID(var msg:TMessage); message WM_NID; //这里的message也有问题
begin
case msg.LParam of
WM_LBUTTONUp: Form1.Visible:=not Form1.Visible;
WM_RBUTTONUP: ShowMessage('right');
End;
End;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NotifyIcon);
end;end.
procedure TForm1.WMNID(var msg:TMessage); message WM_NID; //这里的message也有问
你现在是实现函数,后面不用跟消息了。
改成
procedure TForm1.WMNID(var msg:TMessage);至于其他的。 uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP; //这里的三个参数也报错,说是Undeclared identifier去看看他们是哪个单元定义的常量,引用那个单元了。。我忘记了!
我把procedure WMNID(var msg:TMessage); message WM_NID; 放到 public 里
WMNID过程中的message WM_NID;去掉就可以通过了。
至于那个uFlags:=NIM_ICON or NIM_MESSAGE or NIM_TIP;我很是纳闷。
代码重新复制粘贴一遍就没有错了。
真是奇怪。