您的位置:首页 > 其它

窗体自适应分辨率

2013-01-30 15:03 274 查看
窗口、控件以及字体大小均随分辨率而变化,让界面适应各种不同的分辨率。

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: