Delphi自适应分辨率(比较完美的一个方法)
procedure TfrmMain.FormCreate(Sender: TObject); //主窗体FormCreate事件
var FWidth:integer;
begin
if (screen.Width <> 1024) then //假设你设计程序时的分辨率为1024
begin
FWidth:=width;
scaled:=true;
Font.Size:=(Width div FWidth)*Font.Size;
scaleby(screen.Width,1024);
Height:=longint(Height)*longint(Screen.Height) DIV 768;
Width:=longint(Width)*longint(Screen.Width) DIV 1024;
end;
end;
这是以前项目用过的一段自适应分辨率的代码,效果还不错,不过字体最好调整为宋体。
相关文档:
Delphi中建议使用的语句
楼主zswang(伴水清清)(专家门诊清洁工)2002-05-15 13:37:54 在 Delphi / VCL组件开发及应用 提问
No.1 判断逻辑类型
var B: Boolean;
begin
B := Boolean(2); //这样只是为了调试//B ......
参考资料
李战.《悟透delphi》,第1章“DELPHI的原子世界”
“探索Delphi类与对象的内存结构”
基本知识
动态内存与静态