從lazarus源碼發現,用Scale96ToForm設置控件的高和寬,可以適應不同dpi時控件尺寸保持相對大小。
FForm.Width:= FForm.Scale96ToForm(600); FForm.Height:= FForm.Scale96ToForm(400); FForm.BorderStyle:= bsDialog; FForm.Position:= poScreenCenter; FForm.Caption:= ACaption; FForm.FOnCloseEvent:= ACloseEvent;
還有不同的轉換:
//scale support function ScaleDesignToForm(const ASize: Integer): Integer; function ScaleFormToDesign(const ASize: Integer): Integer; function Scale96ToForm(const ASize: Integer): Integer; function ScaleFormTo96(const ASize: Integer): Integer; function Scale96ToFont(const ASize: Integer): Integer; function ScaleFontTo96(const ASize: Integer): Integer; function ScaleScreenToFont(const ASize: Integer): Integer; function ScaleFontToScreen(const ASize: Integer): Integer; function Scale96ToScreen(const ASize: Integer): Integer; function ScaleScreenTo96(const ASize: Integer): Integer;

浙公網安備 33010602011771號