以下是我照书上做的,新建一应用程序,实现最小化时,只在系统状态栏显示图标的例子。
这个程序运行正常,能够实现效果,为什么我把这些代码复制到我另一个程序里后,编译提示:[Error] Player.pas(131): Undeclared identifier: 'Icon'
说Icon未定义,这是为什么?
在下面这个例子里面就是好的啊?请各位大虾指点!!!我应该在我另一个程序里改点什么内容?急!!在线等待!!!unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI;const
WM_BARICON=WM_USER+200;type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMSysComand(var message: TMessage); message WM_SYSCOMMAND;
procedure WMBarIcon(var message: TMessage); message WM_BARICON;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure tform1.WMSysComand(var message: TMessage);
var
lpData: PNotifyIconData;
begin
if Message.WParam = SC_ICON then
begin
lpData:=new(PNotifyIconDataA);
lpData.cbSize:=88;
lpData.Wnd:=form1.Handle;
lpData.hIcon:=form1.Icon.Handle;
lpData.uCallbackMessage:=WM_BARICON;
lpData.uID:=0;
lpData.szTip:='Samples';
lpData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
Shell_NotifyIcon(NIM_ADD,lpData);
dispose(lpData);
Form1.Visible:=false;
end
else
begin
DefWindowProc(Form1.Handle,Message.Msg,Message.WParam,Message.LParam);
end;
end;procedure tform1.WMBarIcon(var Message: TMessage);
var
lpData: PNotifyIconData;
begin
if (Message.LParam = WM_LBUTTONDOWN) then
begin
lpData:=new(PNotifyIconDataA);
lpData.cbSize:=88;
lpData.Wnd:=form1.Handle;
lpData.hIcon:=form1.Icon.Handle;
lpData.uCallbackMessage:=WM_BARICON;
lpData.uID:=0;
lpData.szTip:='Samples';
lpData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
Shell_NotifyIcon(NIM_ADD,lpData);
dispose(lpData);
Form1.Visible:=true;
end;
end;end.
这个程序运行正常,能够实现效果,为什么我把这些代码复制到我另一个程序里后,编译提示:[Error] Player.pas(131): Undeclared identifier: 'Icon'
说Icon未定义,这是为什么?
在下面这个例子里面就是好的啊?请各位大虾指点!!!我应该在我另一个程序里改点什么内容?急!!在线等待!!!unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI;const
WM_BARICON=WM_USER+200;type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMSysComand(var message: TMessage); message WM_SYSCOMMAND;
procedure WMBarIcon(var message: TMessage); message WM_BARICON;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure tform1.WMSysComand(var message: TMessage);
var
lpData: PNotifyIconData;
begin
if Message.WParam = SC_ICON then
begin
lpData:=new(PNotifyIconDataA);
lpData.cbSize:=88;
lpData.Wnd:=form1.Handle;
lpData.hIcon:=form1.Icon.Handle;
lpData.uCallbackMessage:=WM_BARICON;
lpData.uID:=0;
lpData.szTip:='Samples';
lpData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
Shell_NotifyIcon(NIM_ADD,lpData);
dispose(lpData);
Form1.Visible:=false;
end
else
begin
DefWindowProc(Form1.Handle,Message.Msg,Message.WParam,Message.LParam);
end;
end;procedure tform1.WMBarIcon(var Message: TMessage);
var
lpData: PNotifyIconData;
begin
if (Message.LParam = WM_LBUTTONDOWN) then
begin
lpData:=new(PNotifyIconDataA);
lpData.cbSize:=88;
lpData.Wnd:=form1.Handle;
lpData.hIcon:=form1.Icon.Handle;
lpData.uCallbackMessage:=WM_BARICON;
lpData.uID:=0;
lpData.szTip:='Samples';
lpData.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
Shell_NotifyIcon(NIM_ADD,lpData);
dispose(lpData);
Form1.Visible:=true;
end;
end;end.
解决方案 »
- 咨询Indy的FTP控件下载进度条问题
- 如何在正在播放的flash动画里放进一句自己的话,并且显示出来??
- 求兼职工作
- datetimepick的问题
- 关于进销存及材料库存结转方面的问题!
- 昨天申请了博克,发现csdn还是有不少人去呢。
- 请各位给我一个设计报表的方法!!!急
- 各位朋友请进来看看,有问题请教,带星的也请进来帮忙一下!!
- 虚心请教,Delphi中如何用Excel展现数据库数据
- 谁有InstallShield Express 3.51 的安装密码?
- 在ADO实现的分布式系统中如何实现数据的刷新
- 特郁闷的问题:本人发现DOA控件进行数据库操作时,在多线程并发非同步时存在BUG,而用ODAC控件时问题更郁闷,高手们出手!这可是救命!
forms删掉吧