开发者

How to create splitter containing components?

I'd like to put some buttons between two resizable panels or directly on the splitter if possible. How do I achieve they will move along with the splitter; how do I anchor them ?

How to create splitter containing components?

Edit:

Maybe the most important thing I forgot to mention. That spl开发者_JS百科itter has to be as wide as on the screenshot, and the buttons should lay on it; so those buttons are actually "floating over splitter" now.

Thanks a lot


Yo can't do it automatically.
Manually you can change the Left property of Buttons in OnMoved event of the splitter.
There's not a good solution (visualization on drag moment it's not good), but it can do the result that you need. You can solve this, try ResizeStyle=rsUpdate; With this when you drag the splitter the buttons move too.

procedure TForm1.Splitter1Moved(Sender: TObject);
begin
  SpeedButton1.Left := Splitter1.Left + 40;
  SpeedButton2.Left := Splitter1.Left + 40;
  SpeedButton3.Left := Splitter1.Left + 40;
  SpeedButton4.Left := Splitter1.Left + 40;
end;

Here you can view the result.

Regards


Here's a screenshot from my app:

How to create splitter containing components?

This form has a single TSplitter located to the right of the tree view in the left-hand pane. To the right of the splitter is a TPanel which contains the button.

Here it is at design time and you can see the splitter drawn with a dashed line:

How to create splitter containing components?

The trick is that the splitter doesn't contain controls—for that you use a panel.

So, using your naming you need to replace Splitter1 with a panel to contain the buttons and add a splitter between Panel1 and the new panel. The left and middle panels and the splitter are aligned alLeft and the right handle panel is aligned alClient. Set splitter1.autosnap:= false


You can nest panels inside one another.

+--------------+#+------------+
|+---------+ p |#|  panel3    |
|| panel1  | a |#|            | 
||         | n |#|            |
||         | e |#|            |
||         | l |#|            |
||         | 2 |#|            |

where # is the splitter.

Place the buttons on the right side of panel2.
Or even better put a extra panel4 on panel2, make that

panel4.align:= alRight;
panel1 align:= alClient;
panel2.Align:= alClient;
splitter1.align:= alright or alLeft //experiment here
panel3.Align:= alRight;

This should do the trick.


There is one important notice. Both panels between Splitter should have same parameter AlignWithMargins. (Both true or both false). Otherwise splitter doesn't work. I fought with this problem for few days

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜