我自己在控件写的事件怎么不能调用控件的属性? ( 积分: 50 )

  • 主题发起人 主题发起人 fancyw
  • 开始时间 开始时间
F

fancyw

Unregistered / Unconfirmed
GUEST, unregistred user!
TPanel1 = class(TPanel)
published
procedure CMMouseEnter(var Msg:TMessage);message CM_MouseEnter;
procedure CMMouseLeave(var Msg:TMessage);message CM_MouseLeave;

Procedure TPanel1.CMMouseEnter(var Msg:TMessage);
begin

inherited;
//color:=clwhite;//不能使用color属性

end;
 
TPanel1 = class(TPanel)
published
procedure CMMouseEnter(var Msg:TMessage);message CM_MouseEnter;
procedure CMMouseLeave(var Msg:TMessage);message CM_MouseLeave;

Procedure TPanel1.CMMouseEnter(var Msg:TMessage);
begin

inherited;
//color:=clwhite;//不能使用color属性

end;
 
可以使用的,具体报什么错呢?
 
unit Panel1;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls;

type
TPanel1 = class(TPanel)
private
{ Private declarations }
protected
//procedure CMMouseEnter(var Msg:TMessage);message CM_MouseEnter;
//procedure CMMouseLeave(var Msg:TMessage);message CM_MouseLeave;
{ Protected declarations }
public
{ Public declarations }
published
procedure CMMouseEnter(var Msg:TMessage);message CM_MouseEnter;
procedure CMMouseLeave(var Msg:TMessage);message CM_MouseLeave;
{ Published declarations }
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Samples', [TPanel1]);
end;

Procedure TPanel1.CMMouseEnter(var Msg:TMessage);
begin

inherited;
color:=clwhite;

end;

Procedure TPanel1.CMMouseLeave(var Msg:TMessage);
begin

inherited;
end;

end.
报错是undeclared identifider 'clwhite'
 
你uses 一下 Graphics
 
接受答案了.
 
后退
顶部