Link to home
Start Free TrialLog in
Avatar of Sebastion
Sebastion

asked on

Delphi - Frames - Dymanically removing and adding

Hello,

Just using a basic scenario, lets assume that we have a single form with 2 buttons.  One button says 'display frame one' while the other says 'display frame two'.  In our project, we also have 2 frames (FrameOne and FrameTwo).

How do I display FrameOne when the first button is clicked, and then remove it and display FrameTwo when the second button is clicked.  I think I have the 'remove old frame' right, so I basically just need the 'create new frame' method.  In both cases, the frames are the same size and should be displayed on the same location on the form.
ASKER CERTIFIED SOLUTION
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sebastion
Sebastion

ASKER

Hey Mike,

From what I gather, you're using two different variables (frame1 and frame2).  Is it possible to use just a single variable declared as a TFrame?

Also, with this method, are you just overwriting frame1 with frame2 (and vis versa), or are you freeing up the frame before writing in the new one?
I guess what I mean is whether .free is enough when closing a frame, before opening another.
Yes I am using 2 different frames, but I just assumed that would be what you are doing.
If your using the same frame twice, you would just need to referesh visual details, but then it wouldnt be worth using frames at all.

Yes you can just Free and Nil the frame to clear the variables, depends how often you are switching as to whether you want to keep recreating the form rather than updating on form components.