Forum > Beginners

Custom Component : To create or not to create? That is the question.

(1/2) > >>

TomTom:
Hi,
I think I need to create my own component based on TPageControl but not so sure of that ;)
I'm writing tabs based text editor and I think it would be convinient to add to TTabSheet few custom properties i.e. :

FileName for storing file name of TSynEdit placed on current tab
IsSaved for storing information about state of TSynEdit placed on TabSheet (was it saved or not)

and maybe few other properties in future:)

Or maybe there is other solution? I'm not sure if I have to create custom TPageControl component or custom TTabSheet (never tried to create custom components either from scratch or based on existing one). And how to connect this things?
Well, I've created custom TTabSheet and added to it mentioned above properties, it compiled and it was succesfully added to Component Palatte, but that is no use since I can't add TTabSheet alone to the form :P and I don't know how to test it.

How can I add my TMyTabSheet to TPageControl?

As I'm writing this post I'm also looking into TPageControl code. Now I think that I need to create TMyPageControl AND ALSO TMyTabSheet and add to TMyPageControl additional function AddMyTabSheet. Am I right?
Could anyone kindly point me what I need to look for? Or how to aproach this problem?

Bart:
I did write my own texteditor with a tabbed desing.
I did create a new component based on TPageControl, which has a property Filename...
I did override several methods and added some for my particular needs.
See: http://svn.code.sf.net/p/flyingsheep/code/trunk/EPlus/ and in particular the file editrrpagecontrol.pp there.

I use regular TTabSheets, because I needed no extra functionality from the TTabSheet, I simply create a TSynedit descendant on that with Align:=alClient, so that's all I needed and all the user sees.

Bart

lucamar:
I followed yet another route: I created a frame with a SynEdit control and put all the extras as fields/properties/methods of the frame. Then at runtime I create a frame for each new file whose parent is the corresponding (new) TTabSheet and access everything through it (up to and including loading files, saving them, search/replace, etc.). No subclassing at all (except for the TFrame, of course :) ).

TomTom:
So I will need to get into this :). I think that now I need to create another small project to learn this things (overriding etc) ... oh man:P
I have only small/none experience in those matters :)
Thanks guys :)

lucamar:

--- Quote from: TomTom on January 14, 2019, 03:58:56 pm ---So I will need to get into this :). I think that now I need to create another small project to learn this things (overriding etc) ... oh man:P
I have only small/none experience in those matters :)
Thanks guys :)

--- End quote ---

When I started with my editor (long, long ago ... with Delphi 1) it was a bare, simple Notepad replacement using TMemo. Then I started adding features as I needed them and some that looked cool and so on, writing small programs to test this or the other and all the while learning new and improved ways of doing something.

Now the program is a full-fledged editor-almost-IDE, I rebuilt it from scratch three times and I still keep changing and improving it as I learn new things and ways of doing things.

Everybody has to pass for this: it's the funny side of programming :)

Navigation

[0] Message Index

[#] Next page

Go to full version