I
iyesno
Unregistered / Unconfirmed
GUEST, unregistred user!
(在线等待)我写了一个小控件!!!(代码如下)在它会设计期响应!!请问如何使它在设计期不响应呢?
unit JImage;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TJImage = class(TImage)
private
{ Private declarations }
FNormalBitmap, FHotBitmap: TBitmap;
procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
procedure SetNormalBitmap(Bmp: TBitmap);
procedure SetHotBitmap(Bmp: TBitmap);
public
{ Public declarations }
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property NormalBitmap: TBitmap read FNormalBitmap write SetNormalBitmap;
property HotBitmap: TBitmap read FHotBitmap write SetHotBitmap;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Test', [TJImage]);
end;
constructor TJImage.Create(Owner: TComponent);
begin
inherited;
FNormalBitmap := TBitmap.Create;
FHotBitmap := TBitmap.Create;
end;
destructor TJImage.Destroy;
begin
FNormalBitmap.Free;
FHotBitmap.Free;
inherited;
end;
procedure TJImage.CMMouseEnter(var Msg: TMessage);
begin
//if Assigned(FOnMouseLeave) then FOnMouseLeave(self);
if Assigned(FHotBitmap) then Picture.Assign(FHotBitmap);
end;
procedure TJImage.CMMouseLeave(var Msg: TMessage);
begin
if Assigned(FNormalBitmap) then Picture.Assign(FNormalBitmap);
end;
procedure TJImage.SetNormalBitmap(Bmp: TBitmap);
begin
FNormalBitmap.Assign(Bmp);
// Picture.Assign(FNormalBitmap);
end;
procedure TJImage.SetHotBitmap(Bmp: TBitmap);
begin
FHotBitmap.Assign(Bmp);
end;
end.
unit JImage;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TJImage = class(TImage)
private
{ Private declarations }
FNormalBitmap, FHotBitmap: TBitmap;
procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
procedure SetNormalBitmap(Bmp: TBitmap);
procedure SetHotBitmap(Bmp: TBitmap);
public
{ Public declarations }
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
published
{ Published declarations }
property NormalBitmap: TBitmap read FNormalBitmap write SetNormalBitmap;
property HotBitmap: TBitmap read FHotBitmap write SetHotBitmap;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Test', [TJImage]);
end;
constructor TJImage.Create(Owner: TComponent);
begin
inherited;
FNormalBitmap := TBitmap.Create;
FHotBitmap := TBitmap.Create;
end;
destructor TJImage.Destroy;
begin
FNormalBitmap.Free;
FHotBitmap.Free;
inherited;
end;
procedure TJImage.CMMouseEnter(var Msg: TMessage);
begin
//if Assigned(FOnMouseLeave) then FOnMouseLeave(self);
if Assigned(FHotBitmap) then Picture.Assign(FHotBitmap);
end;
procedure TJImage.CMMouseLeave(var Msg: TMessage);
begin
if Assigned(FNormalBitmap) then Picture.Assign(FNormalBitmap);
end;
procedure TJImage.SetNormalBitmap(Bmp: TBitmap);
begin
FNormalBitmap.Assign(Bmp);
// Picture.Assign(FNormalBitmap);
end;
procedure TJImage.SetHotBitmap(Bmp: TBitmap);
begin
FHotBitmap.Assign(Bmp);
end;
end.