Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change content of TFrame at runtime.

Status
Not open for further replies.

VuurSnikkel

Programmer
Sep 8, 2003
16
NL
Hello there,


I'm currently having trouble "switching frames" at runtime. I've got four different TFrames (as seperate files; I've added them to my project using "New Frame") and I've got a "main" form that has a TFrame on it which I want to use as the container for one of the four seperate frames.

First of all, when I create the container frame on the main form within Delphi, it immediately asks me what frame I want to use as the content. At that point, I'm not interested in the content (I want to decide at runtime), but because of the fact that Delphi forces me to choose a frame, I simply chose the first one of the four seperate frames as the content for my container frame.

I've also got a TComboBox on my main form and with it I want to be able to select one of the four seperate frames as the content for my container frame. And that's where the problems start...

Even when I include the units in which the four seperate frames are stored within the Uses list of my main form, I'm not able to use them in my code like this (just an example of how I tried to switch frames at runtime):

Uses
ContentFrameAUnit;

MainForm.ContainerFrame:=ContentFrameA;

Delphi simply refuses to accept "ContentFrameA" (yes, the names are all right of course).

What is the correct way to do this "farme switching at runtime"? And if - for example - I want to set the DoubleBuffering option of my ContainerFrame to True and I do so at MainForm.FormCreate, will this remain at True even when I load another frame as the content or does the container frame take over the property values of the relevant content frame? Thanks in advance.


GRTZ,

(Sn)Ik.
 
If the problem is at compile time, you may need to insure the the MainForm.ContainerFrame is the same type, or ancestor class of ContentFrameA.

If the problem is at run time, you may need to create the object before assigning it.
ContentFrameA := TContentFrameA.Create(self);
MainFormContainerFrame := ContentFrameA;

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
i'v been trying the same, and i too get stuck because when inserting a frame into a form it is declared as the TYPE of the (at design time) selected frame in stead of the general TFrame. So there is no way to assign another frame (another type) to this placeholder. Come to think of it ... there isn't a placeholder!

I was hoping to using the frames to display a set of controls a number of times, the number to be determent at runtime.


Bascy
Software developer at
 
One way around this may be to use a TPageControl and create four sheets, one containing each frame. Then just change which sheet is visible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top