Jump to content
Guest

Frames, inheritance... How?

Recommended Posts

Guest

I think i have made a grave mistake. Because of DX Ribbons having problems with inheritance, i have put stuff into frames for 2 days now.

 

It goes like this:

TMainFormBase has a frame called FrameBase (TFrameBase). TFramBase is inherited but this is not the problem.

 

Now i would like to inherit from TMainForm, TMainFormApplication. OK. Done.

I would also like to inherit from TFrameBase, say TFrameApplication. OK, done.

 

But how can i say to TMainFormApplication that i want it to use TFrameApplication in stead of TFrameBase?

TMainFormBase accesses functions in TFrameBase using the field "Frame". That must of course continue to work.

Also, TMainFormBase has design-time connections to TFrameBase, like actions in buttons.

 

Any ideas are much appreciated.

 

TIA,

 

/Dany

Edited by Guest
Clarification, TFramTop removed

Share this post


Link to post

First, you should clarify how TMainForm and TMainFormBase are related, as well as TFrameBase and TFrameTop. Disregarding these inconsistencies I will try to outline my solution:

You should avoid placing the frame instance into the form with the designer. Instead declare a field in TMainFormBase of type TFrameBase named Frame. Add a virtual class function CreateFrame returning a TFrameBase instance. During form creation call this function and set the field Frame with the result. Then in TMainFormApplication override that function and return a TFrameApplication.

  • Like 1

Share this post


Link to post
Guest
17 minutes ago, Uwe Raabe said:

First, you should clarify how TMainForm and TMainFormBase are related, as well as TFrameBase and TFrameTop.

Ahrg! TFrameApplication, not TFrameTop. A typo. Fixed. Sorry.

Share this post


Link to post
Guest
18 minutes ago, Uwe Raabe said:

You should avoid placing the frame instance into the form with the designer. Instead declare a field in TMainFormBase of type TFrameBase named Frame. Add a virtual class function CreateFrame returning a TFrameBase instance. During form creation call this function and set the field Frame with the result. Then in TMainFormApplication override that function and return a TFrameApplication.

OK, that could work. Thanks.

 

But then if i have actions on the TFrameBase/TFrameApplication and connect them in the IDE, i'd have to change that into an initialising function that assigns all the actions to all the buttons/other stuff. Am i correct?

Actually, with your proposed solution i will not be able to do the connections design-time anyhow.

Share this post


Link to post

You can still connect these as long as both are inside the frame. If you want to connect buttons of the frame to action in the form: no, that must be done manually.

Share this post


Link to post
Guest

OK! Thanks again, Uwe. Since the frame sat embedded in the dfm i did not think of creating it dynamically in a vitual. I do that with a lot of other stuff.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×