unit highDPIUnit; interface uses CheckLst, Grids, ComCtrls, StdCtrls; procedure gpcItemHeightSet(AComboBox: TComboBox; iHeight: Integer = 0); overload; procedure gpcItemHeightSet(AListBox: TListBox; iHeight: Integer = 0); overload; procedure gpcItemHeightSet(ACheckListBox: TCheckListBox; iHeight: Integer = 0); overload; procedure gpcItemHeightSet(AStringGrid: TStringGrid; iHeight: Integer = 0); overload; procedure gpcDefaultRowHeightSet(AStringGrid: TStringGrid; iHeight: Integer = 0); procedure gpcButtonHeightSet (AButton: TButton); procedure gpcLabelHeightSet (ALabel: TLabel); procedure gpcStatusBarHeightSet(AStatusBar: TStatusBar); const gcfHIGHDPI_FONTSPACE = 1.3; //テキストエリアの高さ(フォントの高さ*倍率) gcfHIGHDPI_CONTROLSPACE = 1.8; //コントロールの高さのマージン(フォントの高さ*倍率) gciHIGHDPI_LABELMARGIN = 2; //Labelの上下マージン(ピクセル) implementation uses Graphics, myNum; function F_CalcHeight(AFont: TFont; iHeight: Integer; fMagni: Extended): Integer; begin Result := gfniMax([Trunc(Abs(AFont.Height) * fMagni), iHeight]); end; function F_CalcControlHeight(AFont: TFont; iHeight: Integer = 0): Integer; begin Result := F_CalcHeight(AFont, iHeight, gcfHIGHDPI_CONTROLSPACE); end; function F_CalcTextHeight(AFont: TFont; iHeight: Integer = 0): Integer; begin Result := F_CalcHeight(AFont, iHeight, gcfHIGHDPI_FONTSPACE); end; procedure gpcItemHeightSet(AComboBox: TComboBox; iHeight: Integer = 0); begin AComboBox.ItemHeight := F_CalcTextHeight(AComboBox.Font, iHeight); end; procedure gpcItemHeightSet(AListBox: TListBox; iHeight: Integer = 0); begin AListBox.ItemHeight := F_CalcTextHeight(AListBox.Font, iHeight); end; procedure gpcItemHeightSet(ACheckListBox: TCheckListBox; iHeight: Integer = 0); begin ACheckListBox.ItemHeight := F_CalcTextHeight(ACheckListBox.Font, iHeight); end; procedure gpcItemHeightSet(AStringGrid: TStringGrid; iHeight: Integer = 0); begin gpcDefaultRowHeightSet(AStringGrid, iHeight); end; procedure gpcDefaultRowHeightSet(AStringGrid: TStringGrid; iHeight: Integer = 0); begin AStringGrid.DefaultRowHeight := F_CalcTextHeight(AStringGrid.Font, iHeight); end; procedure gpcButtonHeightSet(AButton: TButton); begin AButton.Height := F_CalcControlHeight(AButton.Font); end; procedure gpcLabelHeightSet(ALabel: TLabel); begin // ALabel.Height := F_CalcControlHeight(ALabel.Font); ALabel.Height := Trunc(Abs(ALabel.Font.Height)) + (gciHIGHDPI_LABELMARGIN * 2); end; procedure gpcStatusBarHeightSet(AStatusBar: TStatusBar); begin AStatusBar.Height := F_CalcControlHeight(AStatusBar.Font); end; end.