unit untFixForm;

interface

uses
Classes, SysUtils, Controls, Forms; type
TFontedControl = class(TControl)
public
property Font;
end; TFontMapping = record
SWidth:Integer;
SHeight:Integer;
FName:string;
FSize:Integer;
end; procedure FixForm(AForm:TForm);
procedure SetFontMapping; var
FontMapping:array of TFontMapping; implementation procedure SetFontMapping;
begin
SetLength(FontMapping, ); // 800 x 600
FontMapping[].SWidth := ;
FontMapping[].SHeight := ;
FontMapping[].FName := '宋体';
FontMapping[].FSize := ; // 1024 x 768
FontMapping[].SWidth := ;
FontMapping[].SHeight := ;
FontMapping[].FName := '宋体';
FontMapping[].FSize := ; // 1280 x 1024
FontMapping[].SWidth := ;
FontMapping[].SHeight := ;
FontMapping[].FName := '宋体';
FontMapping[].FSize := ; end; procedure FixForm(AForm:TForm);
var
i, j:integer;
t:TControl;
begin
with AForm do
begin
for i := to ComponentCount - do
begin
try
t := TControl(Components[i]);
t.left := Trunc(t.left * (Screen.width / ));
t.top := Trunc(t.Top * (Screen.Height / ));
t.Width := Trunc(t.Width * (Screen.Width / ));
t.Height := Trunc(t.Height * (Screen.Height / ));
except
end; { try }
end; { for i } for i := to Length(FontMapping) - do
begin
if (Screen.Width = FontMapping[i].SWidth) and (Screen.Height =
FontMapping[i].SHeight) then
begin
for j := to ComponentCount - do
begin
try
TFontedControl(Components[j]).Font.Name := FontMapping[i].FName;
TFontedControl(Components[j]).FONT.Size := FontMapping[i].FSize;
except
end; { try }
end; { for j }
end; { if }
end; { for i }
end; { with }
end; initialization
SetFontMapping; end.

SetFontMapping 方法可以自行修改,以适应更多的分辨率。
调用也非常简单,如下所示:

procedure TForm1.FormShow(Sender:TObject);
begin
if MessageBox(Handle, '要使用屏幕自适应吗?', '提示', MB_YESNO or
MB_ICONINFORMATION) = idno then Exit;
untFixForm.FixForm(Self);
end;

http://blog.csdn.net/han_348154920/article/details/4762928

delphi 程序窗体及控件自适应分辨率(通过ComponentCount遍历改变字体大小以及上下左右)的更多相关文章

  1. C# WinForm窗体及其控件自适应各种屏幕分辨率

    C# WinForm窗体及其控件自适应各种屏幕分辨率 一.说明  我们自己编写程序的界面,会遇到各种屏幕分辨率,只有自适应才能显的美观.实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置 ...

  2. C# ——窗体和控件随着分辨率的变化自适应大小

    一.说明 我们自己编写程序的界面,会遇到各种屏幕分辨 率,只有自适应才能显的美观.实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置和大小,当窗体改变比例时,其控件的位置和大小也按此比 ...

  3. C# Winform窗体和控件自适应大小

    1.在项目中创建类AutoSizeForm AutoSizeForm.cs文件代码: using System; using System.Collections.Generic; using Sys ...

  4. Qt窗体内控件自适应调整大小

    http://stackoverflow.com/questions/3492739/auto-expanding-layout-with-qt-designer After creating you ...

  5. WinForm窗体及其控件的自适应

    3步骤: 1.在需要自适应的Form中实例化全局变量   AutoSizeFormClass.cs源码在下方 AutoSizeFormClass asc = new AutoSizeFormClass ...

  6. 转:C# WinForm窗体及其控件的自适应

    一.说明 2012-11-30 曾经写过 <C# WinForm窗体及其控件自适应各种屏幕分辨率>  ,其中也讲解了控件自适应的原理.近期有网友说,装在panel里面的控件,没有效果? 这 ...

  7. Winfon 页签切换及窗体控件自适应

    由于公司的业务调整,最近不仅开发bs,还有不熟悉的cs,人手也不足,项目还多,对于cs来说,算是小白,虽然是一个人,也是硬着头皮写,拖拽控件,自定义控件.一个项目下来,对cs有了很深的认识,这里好好感 ...

  8. C# WinForm窗体及其控件的自适应

    3步骤: 1.在需要自适应的Form中实例化全局变量   AutoSizeFormClass.cs源码在下方 AutoSizeFormClass asc = new AutoSizeFormClass ...

  9. 【Winfrom-适配窗体】 WinForm窗体及其控件的自适应,控件随着窗体变化

    在Winform中,窗体最大化之后,控件仍然保持原来的大小,就会显得不好看,那么有什么办法让控件跟着窗体变化吗? 在需要自适应的Form中代码如下:(AutoSizeFormClass.cs源码在下方 ...

随机推荐

  1. supervisor:进程管理工具

    一,安装(任何一种方式) apt-get install supervisor easy_install supervisor pip install supervisor 二,配置 配置superv ...

  2. GDB错误:Cannot find bounds of current function

    http://blog.csdn.net/zoomdy/article/details/17249165 mingdu.zheng <at> gmail <dot> com 使 ...

  3. String Format for DateTime [C#]

    This example shows how to format DateTime using String.Format method. All formatting can be done als ...

  4. 计算两点距离 ios

    //计算两点距离 -(float)distanceBetweenTwoPoint:(CGPoint)point1 point2:(CGPoint)point2 { ) + powf(point1.y ...

  5. [ES6] Converting an array-like object into an Array with Array.from()

    Array.from() lets you convert an "iterable" object (AKA an array-like object) to an array. ...

  6. IIS部署FTP服务器步骤

    本文介绍如何在IIS中部署FTP服务端.首先确认windows开启了ftp功能:确认方法:进入控制面板->程序->打开或关闭windows功能如下图所示: 确认FTP勾选 确认后打开IIS ...

  7. 自定义控件(视图)2期笔记05:自定义控件之继承自View(滑动开关)

    1.  开关按钮点击效果,如下: 2. 继承已有View实现自定义View 3. 下面通过一个案例实现滑动开关的案例: (1)新建一个新的Android工程,命名为" 开关按钮", ...

  8. 顺序表JAVA代码

        publicclassSeqList{       final int defaultSize =10;     //默认的顺序表的最大长度     int maxSize;          ...

  9. /dev/null 文件

    /dev/null 文件 如果希望执行某个命令,但又不希望在屏幕上显示输出结果,那么可以将输出重定向到 /dev/null: $ command > /dev/null /dev/null 是一 ...

  10. 进程ps、kill 、grep

    linux上进程有5种状态: 1. 运行(正在运行或在运行队列中等待) 2. 中断(休眠中, 受阻, 在等待某个条件的形成或接受到信号) 3. 不可中断(收到信号不唤醒和不可运行, 进程必须等待直到有 ...