秋·风

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
从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;

 

posted on 2025-07-06 06:30  秋·风  阅读(133)  评论(0)    收藏  举报