【发布时间】:2021-04-08 02:20:33
【问题描述】:
我是一名长期的 Delphi VCL 开发人员,我刚刚开始学习 FMX。我创建了一个简单的小应用程序,它在内部显示 ClientHeight、ClientWidth、FormFactor.Width 和 FormFactor.Height OnResize 事件处理程序中的 TMemo。
这些是默认尺寸:
- 客户端高度 = 381
- 客户端宽度 = 420
- Formactor.Width = 320
- FormFactor.Height = 480
为什么FormFactor.Width和FormFactor.Height在应用主窗口调整大小时没有变化?
表单代码
object Form1: TForm1
Left = 0
Top = 0
BorderIcons = [biSystemMenu]
Caption = 'Form1'
ClientHeight = 381
ClientWidth = 420
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnResize = FormResize
DesignerMasterStyle = 0
object Memo1: TMemo
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
DataDetectorTypes = []
Align = Center
Anchors = [akLeft, akTop, akRight, akBottom]
Size.Width = 385.000000000000000000
Size.Height = 333.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
Viewport.Width = 381.000000000000000000
Viewport.Height = 329.000000000000000000
end
object StatusBar1: TStatusBar
Position.Y = 359.000000000000000000
ShowSizeGrip = True
Size.Width = 420.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
end
end
程序代码
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types,
FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
StatusBar1: TStatusBar;
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.FormResize(Sender: TObject);
begin
Memo1.Lines.clear;
Memo1.Lines.Add('ClientHeight:' + #9#9 + Form1.ClientHeight.ToString);
Memo1.Lines.Add('ClientWidth:' + #9#9 + Form1.ClientWidth.ToString);
Memo1.Lines.Add('FormFactor.Width:' + #9 + Form1.FormFactor.Width.ToString);
Memo1.Lines.Add('FormFactor.Height:' + #9 + Form1.FormFactor.Height.ToString);
end;
end.
【问题讨论】:
-
请看documentation。它似乎只涉及 iOS,并根据目标设备选择而变化。
-
谢谢@TomBrunberg。我查看的是库帮助页面,而不是 RADStudio 帮助页面。
-
不客气
标签: delphi firemonkey