组件开发(100分)

  • 主题发起人 主题发起人 dyonghua
  • 开始时间 开始时间
D

dyonghua

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
type
TPageClass=class(TPersistent)
private
FTop,FLeft,FRight,FBottom:Integer;
published
property Top:Integer Read FTop write FTop;
property Left:Integer Read FLeft write FLeft;
property Right:Integer Read FRight write FRight;
property Bottom:Integer Read FBottom write FBottom;
end;
TPrintPanel = class(TCustomPanel)
private
{ Private declarations }
Fpage:TPageClass;
procedure SetBound(const Value:TPageClass);
protected
{ Protected declarations }
procedure paint;override;
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
property Canvas;
property Page:TPageClass read Fpage write SetBound;
end;
TEhPrint=class(TPrintPanel)
private
public
published
property Page;
end;

procedure Register;

implementation
procedure Register;
begin
RegisterComponents('dyonghua', [TEhPrint]);
end;

{ TPrintPanel }


constructor TPrintPanel.Create(AOwner: TComponent);
begin
inherited create(AOwner);
Width:=200;
Height:=300;
Fpage:=TPageClass.Create;
Top:=1;
Left:=1;
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
csOpaque, csDoubleClicks, csReplicatable];
Alignment := taCenter;
BevelOuter := bvNone;
BorderStyle := bsNone;
Color := clWhite;
FullRepaint := True;
UseDockManager := True;
end;

destructor TPrintPanel.Destroy;
begin
Fpage.Free;
inherited;
end;

procedure TPrintPanel.paint;
begin
inherited paint;
Canvas.Pen.Color:=clRed;
Canvas.Pen.Style:=psDot;
Canvas.Rectangle(Fpage.FLeft,Fpage.FTop,Width-Fpage.FRight,Height-Fpage.FBottom);
end;
{ TPageClass }

procedure TPrintPanel.SetBound(const Value: TPageClass);
begin
end;

{ TPageClass }

end.
要求在更改TPage的属性时TPrintPanel发生Paint。
 
在setbound中调用paint函数没有用吗?
 

Similar threads

I
回复
0
查看
527
import
I
I
回复
0
查看
728
import
I
I
回复
0
查看
547
import
I
I
回复
0
查看
633
import
I
后退
顶部