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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you actually use splitters with panels!?

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I've tried and searched for tips and examples, but this seemingly simple thing has got me beat.
Delphi help, and other web pages I found say place panel, set align, place splitter, set align same, place panel, set align to client, whoosh you're away.
Umm, not. I must be missing something fundamental.
I get the usual cursor type like when you are over a draggable windows control, but nothing happens. I've tried all the properties on the panels that look likely.

What I am trying to actually do, if I can get past step 1 is to have 3 horizontal panels on my form. I want there to be a draggable splitter at each panel to panel junction.
When you drag either of these, you move the centre panel up or down (to a predefined limit-min size property I guess) but the centre panel must never change height. I'm assuming a max and min constraint the same should fix that bit?

But how do I make these splitters work please?


Steve (Delphi 2007 & XP)
 
make sure your putting the splitters on the form between the panels not on the panels themself.

form[panel1.alignright|splitter|panel2.align.client]form

Aaron
 
If it helps, here's a simple example, much taken from the Delphi help, but extended some (throw the identified controls on the form):

Code:
TForm1 = class(TForm)
    DriveComboBox1: TDriveComboBox;
    DirectoryListBox1: TDirectoryListBox;
    FileListBox1: TFileListBox;
    Splitter1: TSplitter;
    Splitter2: TSplitter;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
..

procedure TForm1.FormCreate(Sender: TObject);
begin
  { define parent and alignment of DirectoryListBox }
  DirectoryListBox1.Parent := Form1;
  DirectoryListBox1.Align := alLeft;
  { define parent splitter size for vertical }
  Splitter1.Parent := Form1;
  Splitter1.Left := DirectoryListBox1.Left + DirectoryListBox1.Width + 1;
  Splitter1.Align := DirectoryListBox1.Align;
  { define parent and alignment for filelistbox }
  FileListBox1.Parent := Form1;
  FileListBox1.Align := alClient;
  { define horizontal splitter and alignment }
  Splitter2.Parent := Form1;
  Splitter2.Top := DriveComboBox1.Top + DriveComboBox1.Height + 1;
  Splitter2.Align := Splitter1.Align;
  { define parent and alignment for DriveComboBox }
  DriveComboBox1.Align := alTop;
  DriveComboBox1.Parent := Form1;
  { linkages for all boxes }
  DirectoryListBox1.FileList := FileListBox1;
  DriveComboBox1.DirList := DirectoryListBox1;
end;

But I'm not sure exactly what you're wanting. By implication of the splitter, the center panel would change height if it is moved.

I'm not sure splitters are what you want, truthfully.
 
Thanks Aaron and Glen.
Yes, I was dropping the splitter on the panel, Doh!!

Thanks for the runtime example Glenn.

What I am doing looks like this:

And this is working almost how I want.
I've made Panel2 keep a fixed height if you drag the splitter, but I am finding only the top splitter works. If I drag the lower splitter the panels do not resize.

Is there a way to rectify that?


Steve (Delphi 2007 & XP)
 
It works best if the second panels Align properties is set to alClient.


Roo
Delphi Rules!
 
Roo, you may recall this one I posted before:

Now I'm actually trying to simulate this, can I take you up on your offer if possible please.
Let me explain what the picture on the link can't.
Indeed, clicking on the graphic pops the panel in and out.
But the rest of the 'bar' acts like (or is?) a splitter, so you can drag the right hand panel in and out to resize it too.
I can recreate that part OK, but I'm failing to get a graphic on there to do the clickable part.
FYI, the graphic doesn't have a buttondown version of the image.


Steve (Delphi 2007 & XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top