?
Solved

switch between frames

Posted on 2007-10-11
3
Medium Priority
?
220 Views
Last Modified: 2010-04-05
I have to keep switching between many Frames.
(Outlook style sidebar/application)
What is the best way to hide/show a frame on button click ?
I use form as parent i.e..
Frame2.Parent := Form1;
Frame2.Align := alClient;
Frame2.show;
0
Comment
Question by:senad
3 Comments
 
LVL 19

Expert Comment

by:MerijnB
ID: 20056765
TFrame has a .visible property, is that what you need?
0
 
LVL 1

Expert Comment

by:rambolivia
ID: 20056805
Hi senad,

I would suggest you place your frames on a TPageControl.  You can hide the Tabs by setting the TabVisible property to false (this property is on each tab).

It is a good idea to set the TabVisible property to false on runtime so that the tabs can help you during design time.

You can easily switch between frames using the TPageControl.TabIndex property.

Hope it helps!!!!

R.
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 200 total points
ID: 20062181
There are several ways to do what you want
Firstly, if your frame tkes up the entire control(form1 for instance) then
you can hide the other frame(s) and show your desired one
procedure TForm1.bShowFrame1Click(Sender: TObject);
begin
  Frame2.Hide;
  Frame1.Show;
end;

procedure TForm1.bShowFrame2Click(Sender: TObject);
begin
  Frame1.Hide;
  Frame2.Show;
end;

Secondly, If you are not using align (alClient) then you could show all the frames, and simply bring the desired one to the foreground
procedure TForm1.bFrame1InFrontClick(Sender: TObject);
begin
  Frame1.BringToFront;
end;

procedure TForm1.bFrame2InFrontClick(Sender: TObject);
begin
  Frame2.BringToFront;
end;

Thirdly, if you are using align (alTop, alClient) and you wish the "unfocused" frames to shrink (so you can display just a label for expanding again) andshow your desired frame in a large size, you can do something like this :-

procedure TForm1.bMaximizeFrame1Click(Sender: TObject);
begin
  Frame2.Align := alTop;
  Frame2.Height := 20;
  Frame1.Align := alClient;
end;

procedure TForm1.bMaximizeFrame2Click(Sender: TObject);
begin
  Frame1.Align := alTop;
  Frame1.Height := 20;
  Frame2.Align := alClient;
end;

fourthly, you could do the same as above, but not use teh align property, and specifically assign the top, left, width and height.
This would be particularly useful if your "bar" has a scrollbar

procedure TForm1.bResizeFrame1Click(Sender: TObject);
begin
  Frame1.Height := 100;
  Frame2.Top := 104;
  Frame2.Height := 20;
end;

procedure TForm1.bResizeFrame2Click(Sender: TObject);
begin
  Frame1.Height := 20;
  Frame2.Top := 24; // the sum of all the shrunken frames above this one
  Frame2.Height := 100;
end;

hth, Loki
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses

750 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