J
jackyxinli
Unregistered / Unconfirmed
GUEST, unregistred user!
我自己编了几个从TGraphicControl继承来的控件,我想将其合并为一个控件,我写了如下的代码,但是不成功:
type
TzzLEDClock = class(TGraphicControl)
private
FHourMinute: TzzLEDHourMinute;
FSecond: TzzLEDSecond;
FAmPm: TzzLEDAMPM;
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
end;
implementation
constructor TzzLEDClock.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHourMinute := TzzLEDHourMinute.Create(Self);
FSEcond := TzzLEDSecond.Create(Self);
FAmPm := TzzLEDAMPM.Create(Self);
FHourMinute.Visible := True;
FSecond.Visible := True;
FAmPm.Visible := True;
end;
destrucor TzzLEDClock.Destroy;
begin
FHourMinute.Free;
FSecond.Free;
FAmPm.Free;
inherited Destroy;
end;
procedure TzzLEDClock.Paint;
var
MBitmap: TBitmap;
begin
MBitmap := TBitmap.Create;
MBitmap.Width := Width;
MBitmap.Height := Height;
MBitmap.Canvas.FillRect(Rect(0, 0, Width, Height));
MBitmap.Canvas.CopyMode := cmSRCCOPY;
MBitmap.Canvas.CopyRect(Rect(0,0,61,22), FHourMinute.Canvas, Rect(0,0,61,22));
end;
请问如何解决这个问题?
type
TzzLEDClock = class(TGraphicControl)
private
FHourMinute: TzzLEDHourMinute;
FSecond: TzzLEDSecond;
FAmPm: TzzLEDAMPM;
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
end;
implementation
constructor TzzLEDClock.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHourMinute := TzzLEDHourMinute.Create(Self);
FSEcond := TzzLEDSecond.Create(Self);
FAmPm := TzzLEDAMPM.Create(Self);
FHourMinute.Visible := True;
FSecond.Visible := True;
FAmPm.Visible := True;
end;
destrucor TzzLEDClock.Destroy;
begin
FHourMinute.Free;
FSecond.Free;
FAmPm.Free;
inherited Destroy;
end;
procedure TzzLEDClock.Paint;
var
MBitmap: TBitmap;
begin
MBitmap := TBitmap.Create;
MBitmap.Width := Width;
MBitmap.Height := Height;
MBitmap.Canvas.FillRect(Rect(0, 0, Width, Height));
MBitmap.Canvas.CopyMode := cmSRCCOPY;
MBitmap.Canvas.CopyRect(Rect(0,0,61,22), FHourMinute.Canvas, Rect(0,0,61,22));
end;
请问如何解决这个问题?