Solved

two simple inheritance questions

Posted on 2006-07-19
2
196 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

Technology Partners: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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