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!

Embeded Frames?

Status
Not open for further replies.

SpeedDemon

Programmer
Jan 1, 2001
70
GB
Hi all, pretty new to delphi, what im asking is probably something real simple :)

Anyhow... take a look at my screen grab here...

Right, on each tab i'd like to put 2 buttons, simple enough, however depending on which button is clicked, i want to alter the entire content in the tab (page control thing).

If button 1 is clicked, a certain form is displayed in the tab, if the other button is clicked, a different form is displayed in the tab.

I may have my definitions wrong (probably do :) ), so, any ideas how I can do this?

Thanks to all!
Cheers
 
SpeedDemon,

You want something like this:

Code:
   PageControl1.ActivePage := TabSheet2;

Where TableSheet2 is the name of the Tabsheet you want to become active when the use clicks your button.

Hope this helps...

-- Lance
 
Hi, thanks for the reply.

Im not quite sure what you mean, i've done another screen grab...



Take a look.

Right, depending on which button is clicked (Add user or Edit details) I want a different 'form' to appear where the 'panel' is.

Can I do this?

Cheers
 
SpeedDemon,

Sorry, I misunderstood. That's how I usually approach this type of thing, e.g. I use a second page control as the target panel and then add Tabsheet pages for each subform. Once you've done that, you can display the appropriate subform simply by changing the ActivePage property of the second PageControl.

You *can* assign the parent window of a form with a bit of trickery:

Code:
procedure SetWindowParent(const WindowParent: TWinControl;
  var Params: TCreateParams);
begin
  with Params do begin
    WndParent := WindowParent.Handle;
    Style := (Style or ws_Child)
      and not (ws_Popup)
      and not (ws_Border)
      and not (ws_ThickFrame)
      and not (ws_DlgFrame);
  end;
end;

Typically, this type of thing was required in Windows 3.x, which severely limited the number of windows handles and it was easy to run out of them in complex applications with a lot of forms.

We don't have that problem these days, so I generally avoid such tricks. (Sometimes, the simplest answers are the easiest to maintain.) However, if it's what you're looking for, feel free. Just be sure you provide appropriate code to manage the resources; otherwise, you may leak resources like a sieve.

Hope this helps...

-- Lance
 
Hi mate, thanks for the reply.

I think i solved my problem... but it has led to another :)

I made a 'frame' by going to New | Frame

Once i'd made the frame, i simply put it into my main form using a frame component.

Now my problem, do you know how I could switch the embeded frame with a different one when the input buttons are clicked?

Cheers
 
You can use Frame.Visible := false to hide the frame you dont want and Frame.visible := true to show the frame you want depending on what button is pressed.

This looks bad at design time because you must have both frames on the form >:):O> , but will work ok at runtime.

You can experiment with this anyway and see what you think.
 
Nice one bud, works a treat and looks a feast at runtime :)

I'm not used to Object Orientated stuffs, really cool, love it in fact! :)

Cheers again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top