Solved

two simple inheritance questions

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy file in dll not working but working on exe ! 18 92
Best Firemonkey component pack 1 101
Create a path if not exists 7 76
Unique identifier on a terminal server (rdp) 4 52
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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 …

785 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