窗体自适应分辨率
窗口、控件以及字体大小均随分辨率而变化,让界面适应各种不同的分辨率。
var
FWidth: Integer;
begin
inherited;
if (Screen.width <> 1024) then
begin
FWidth := Self.width;
Scaled := True;
Font.Size := (Self.width DIV FWidth) * Font.Size; // 字体大小调整
ScaleBy(Screen.width, 1024); // 控件大小调整
Self.Height := longint(Height) * longint(Screen.Height) DIV 768;
Self.width := longint(width) * longint(Screen.width) DIV 1024; // 窗口大小调整
end;
FScale := Screen.width / 1024;
if FScale <> 1 then
begin
for i := 0 to DBGrid1.Columns.Count - 1 do
begin
if DBGrid1.Columns[i].Visible then
begin
DBGrid1.Columns[i].width := Trunc(DBGrid1.Columns
[i].width * FScale);
end;
end;
end;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/archive/2013/01/30/2883043.html