【问题标题】:Correct way to change WIndow Size before showing在显示之前更改窗口大小的正确方法
【发布时间】:2017-03-04 08:58:25
【问题描述】:

我已经从 XE7 移出项目,在子窗体的 OnCreate 中我正在更改窗口的大小,该窗体具有 Position := MainFormCenter。

现在在柏林,在显示此子表单后,我有 Left = 0 和 Top = 0。如果在 OnCreate 中没有改变窗口大小,那么这个子窗体会正确创建并且它位于主窗体的中心。

我现在应该如何在 Delphi Berlin 初始化期间更改表单大小而不丢失表单位置设置?

此处的表单位置更改为 TFormPosition.Designed:

unit FMX.Forms

procedure TCommonCustomForm.Show;
var
  LPosition: TFormPosition;
...
begin
...
          // If you changed the original coordinates or size
          if TBoundChange.Location in FBoundChanges then
          begin
            if LPosition = TFormPosition.Default then
              LPosition := TFormPosition.DefaultSizeOnly
            else if LPosition in [TFormPosition.DefaultPosOnly, TFormPosition.ScreenCenter, TFormPosition.DesktopCenter,
              TFormPosition.MainFormCenter, TFormPosition.OwnerFormCenter] then
              LPosition := TFormPosition.Designed; // Changed here to Default
          end;
...
end;

更新:

我发现的一种方法 - 从表单的 OnShow 方法更改大小

【问题讨论】:

    标签: delphi delphi-10.1-berlin


    【解决方案1】:

    没有其他答案 - 解决此问题的一种方法是在表单的 OnShow 方法中更改表单大小

    【讨论】:

      猜你喜欢
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-09
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 2011-12-10
      相关资源
      最近更新 更多