主题:断承
大家好,我又有一个问题要问大家了。代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TLabel=class(StdCtrls.TLabel)
private
procedure LBMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure LBMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
end;
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TLabel.LBMouseEnter(var Message: TMessage);
begin
inherited;
Form1.Label1.Caption:='进来';
end;
procedure TLabel.LBMouseLeave(var Message: TMessage);
begin
inherited;
Form1.Label1.Caption:='出去';
end;
end.
这样只要鼠标在Label上移动Label1的caption就会改变。我是要鼠标只有在Label1上移动时Label1的Caption才会改变。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TLabel=class(StdCtrls.TLabel)
private
procedure LBMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
procedure LBMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
end;
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TLabel.LBMouseEnter(var Message: TMessage);
begin
inherited;
Form1.Label1.Caption:='进来';
end;
procedure TLabel.LBMouseLeave(var Message: TMessage);
begin
inherited;
Form1.Label1.Caption:='出去';
end;
end.
这样只要鼠标在Label上移动Label1的caption就会改变。我是要鼠标只有在Label1上移动时Label1的Caption才会改变。