Fla*_*der 4 delphi vcl delphi-xe6
似乎有align
一个非常好的属性,但是可以对齐元素,这样如果所有元素都小于容器的大小,那么面板上的所有元素都将对齐到彼此底部的所有元素?像顶部中心的东西.
像这样的东西:
或至少水平,垂直,他们可以100%.
将元素放入自己的容器中,例如a TPanel
或者TFrame
是主容器的子容器.将子容器的Align
属性设置为alCustom
并使用父容器的OnAlignPosition
事件来保持子容器居中于自身:
// Panel1 is the Parent container for the child panel...
procedure TMyForm.Panel1AlignPosition(Sender: TWinControl; Control: TControl;
var NewLeft, NewTop, NewWidth, NewHeight: Integer; var AlignRect: TRect;
AlignInfo: TAlignInfo);
begin
if Control = ChildPanel then
begin
NewLeft := AlignRect.Left + ((AlignRect.Width - Control.Width) div 2);
NewTop := AlignRect.Top + ((AlignRect.Height - Control.Height) div 2);
end;
end;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4755 次 |
最近记录: |