当前位置:网站首页>Delphi自动适应屏幕大小
Delphi自动适应屏幕大小
2022-04-22 02:36:00 【海宏AA】
Delphi自动适应屏幕大小
//自动适应屏幕大小:作者:海宏软件,周承昊。
function autoFitScreen640_480(oContainer:TWinControl):Boolean;
const defaultScreenWidth=800; defaultScreenHeight=600;
var i,j:integer; n:double; v:Variant;
cmt:TComponent; obj:TObject;
ppi:pPropInfo; fnt:TFont;
begin
result:=false;
//分辨率自适应
if (screen.width < defaultScreenWidth) then with oContainer do begin
height:=longint(height) * longint(screen.height) DIV defaultScreenHeight;
width := longint(width) * longint(screen.width) DIV defaultScreenWidth;
scaleBy(screen.width, defaultScreenWidth);
//缩放字体,属性设置部分参考:http://topic.csdn.net/t/20030423/20/1699661.html
n:=(screen.Width / defaultScreenWidth);
for i:=ComponentCount-1 downto 0 do begin
cmt:=components[i];
with cmt do begin
ppi:=GetPropInfo(cmt, 'font'); //ClassInfo取对象的属性值
//有此属性 PropInfo^.PropType^.Kind = tkClass
if (ppi<>nil) and (ppi^.PropType^.Kind=tkClass) then begin
obj:=GetObjectProp(cmt, 'font'); //获取对象的属性对象
if (not assigned(obj)) then continue;
fnt:=obj as TFont; //取得字体
//计算出新的字体
j:=trunc( (fnt.size * screen.Width) / defaultScreenWidth);
if j<7 then j:=9 else if j<8 then j:=9;
//设置字体font.size := j;
fnt.Size:=j;
SetObjectProp(cmt, 'font', fnt);
end;
end;
end;
end;
end;
版权声明
本文为[海宏AA]所创,转载请带上原文链接,感谢
https://blog.csdn.net/gssystems/article/details/5850611
边栏推荐
- Complete solution of closure operation in Discrete Mathematics
- Analysis and interpretation of the current situation and challenges faced by enterprise operation and maintenance in the digital era
- The accuracy of Microsoft's new tools is 80%? Programmer: Thank you
- Understanding of threads in signal catcher threads
- Embedded AI
- Eight common probability distribution formulas and visualization
- Why does MySQL index use B + tree instead of jump table?
- C语言字符分类与转换
- 刷题笔记:剑指offer 04.二维数组中的查找——一个报错
- XSS跨站脚本攻击学习记录
猜你喜欢

Dump mangodb data using Navicat
![[※ leetcode refers to the path in offer 12. Matrix (simple)]](/img/88/2c1c7a9954d824495f0b99223ce7fc.png)
[※ leetcode refers to the path in offer 12. Matrix (simple)]

Financial information security training - 22 / 4 / 19 (Part I)

使用navicat将mangodb的数据做转储

How does ECS connect to ad domain or LDAP user source

Plug in import and usage of uni list
![[paper reading] active class incremental learning for balanced datasets](/img/20/ecfffcdeed6813a6bdb703794a2607.png)
[paper reading] active class incremental learning for balanced datasets

Will you "sell" SQL?

2022年物联网安全的发展趋势

Alibaba P9 explains high concurrency in detail, and shows you how Taobao can resist large-scale second kill activities such as double 11
随机推荐
Line feed in string value when sqlserver parses JSON
XSS cross site script attack learning record
Pv-tsm principle and MATLAB simulation
二叉排序树基本性质详解
How does ECS connect to ad domain or LDAP user source
Why can the Internet industry attract more and more young people? Especially programmers
离散数学(Closure operation)闭包运算全解
详解各类云计算模型,企业如何使用每种模型提高业务生产力?
Unapp encapsulates a loading animation
Training set: alexnet classification
What do you learn about programming
Unity game optimization - third edition reading notes Chapter 1 analyze performance problems
Ren Jie, chief scientist of rongyun: the Internet is unstoppable, but there are always young people
Can initialization process
2022 software designer examination knowledge points: linear table
STM32 can communication experiment
Is it safe to open an account online? How to open an account better?
2022年软件设计师考试知识点:线性表
golang 1.8泛型测试
Explain various cloud computing models in detail. How can enterprises use each model to improve business productivity?