Solved

two simple inheritance questions

Posted on 2006-07-19
2
188 Views
Last Modified: 2010-04-05
Hello there...two simple questions.

I'm making a tabbed text editor. So, multiple files are open at the same time. Ok, now I realised that inheriting a new richeedit would be just great to solve some problems: know the complete file name of the text file opened in each tab, know if text is saved or if it contains modifications that were not saved.

However, when I sat to do this..I found out it was not as easy as I supposed. First question: how do I override a property? specially if it´s an event. For example, RichEdit's OnChange event. I would like to do something and then let the inherited OnChange do it's part. Second question: how do I override a Richedit's Line.Save/LoadToFile properties? I mean, they are not simple methods that correspond directly to the Richedit class..they correspond to an object incorporated to that class.

Examples (even if they are short) would be greatly appreciated!

thanx in advance,
paul.
0
Comment
Question by:pin_plunder
2 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 25 total points
ID: 17144289
Use frames instead. Create a new frame, give it the additional properties that you like and on your TabControl all you have to do is add new frames of this frame class. Much less complicated than having to make a new TRichEdit class.
0
 
LVL 6

Assisted Solution

by:House_of_Dexter
House_of_Dexter earned 25 total points
ID: 17146751
k...for one you don't want to override the functionality of Line...that is decendended from TStrings and is tied into TCustomMemo...

You want to override TRichEditStrings and add a new functionality there...you will need to override the constructor and create a new TRichEditStrings...


OR

just expose the Methods you want...  TMyRichEditStrings.LoadToFile and TMyRichEditStrings..SaveLine.

Now on to your OnChange...

first redeclare the OnChange property

private
  FOnChangeNew: TNotifyEvent;
protected
  procedure DoChange(Sender: TObject);
public

Property OnChange: TNotifyEvent read FOnChangeNew write FOnChangeNew;


constructor Create
....
  Self.OnChange := DoChange;


procedure TMyRichEditStrings.DoChange(Sender: TObject);
begin
  //  Do my expanded changes here...
  if Assigned(FOnChangeNew) then
    FOnChangeNew(Self);
end;
 
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now