Link to home
Start Free TrialLog in
Avatar of isaka
isaka

asked on

Creating TMyPageControl component

What I want to do is creating a Custom component descendant from TPageControl like:
TMyPageControl = class(TPageControl)

but what I realy need is inserting new property items on TTabSheet control like:

TMyTabSheet = class(TTabSheet)
property Item1;
property Item2;
property Item3;

and this TMyTabSheet to be linked with TMyPageControl.
So how can I link this to controls and to function on the same way as TPageControl?

Thank you
Avatar of edey
edey

you just declare your new tabsheet (TMyTabSheet), create an instance of it & set it's pageControl property to your pageControl.

Gl
Mike
here I have an example clipped from a text editor I have written:

  TMySheet = class(TTabSheet)
  private
     fFileName : string;
     procedure setFileName(value : string);
  public
     text : TRichEdit;
     property fileName : string read fFileName write setFileName;
     constructor create(AOwner : TComponent);override;
  end;

constructor TMySheet.create(AOwner : TComponent);
begin
     inherited;
     text := TRichEdit.create(self);
     text.parent := self;
     text.align := alClient;
     text.modified := false;
     text.ScrollBars := ssBoth;
     text.PlainText := form1.CheckBox1.Checked;
     form1.toolbutton3.down := form1.checkbox1.checked;
     text.WordWrap := form1.checkbox5.checked;
     form1.toolButton2.Down := form1.checkbox5.checked;
     text.WantTabs := true;
     text.WantReturns := true;
     fFileName := '';
end;

procedure TForm1.New1Click(Sender: TObject);
var
   t : TMySheet;
begin
     t := TMySheet.create(noteBook);
     with t do
     begin
          parent := notebook;
          pageControl := noteBook;
     end;
     notebook.ActivePage := t;
     noteBookChange(self);
end;



GL
Mike
Avatar of isaka

ASKER

Thank you Mike on you answer,

But in this way I can't make a component which work at design time.

isak
Avatar of isaka

ASKER

Adjusted points from 50 to 100
ASKER CERTIFIED SOLUTION
Avatar of mullet_attack
mullet_attack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of isaka

ASKER

It works perfect.
Thank you for your brilliant answer.