Solved

two simple inheritance questions

Posted on 2006-07-19
2
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
can't find the executable in Simulator 1 112
SUM 2 INTEGER ARRAYS INTO 1 10 111
Base1 Encode/Decode 3 86
Delphi: making a BW image transparent 10 92
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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