对于代码
edt3.Width := Round( edt3.Width * nuw );
edt3.Left := Round( edt3.Left * nuw );
edt3.Height := Round( edt3.Height * nuh );
edt3.Top:=Round( edt3.Top * nuh);
edt3.Font.Size := Round( edt3.Font.Size *nuh);
edt4.Width := Round( edt4.Width * nuw );
edt4.Left := Round( edt4.Left * nuw );
edt4.Height := Round( edt4.Height * nuh );
edt4.Top:=Round( edt4.Top * nuh);
edt4.Font.Size := Round( edt4.Font.Size *nuh);
edt5.Width := Round( edt5.Width * nuw );
edt5.Left := Round( edt5.Left * nuw );
edt5.Height := Round( edt5.Height * nuh );
edt5.Top:=Round( edt5.Top * nuh);
edt5.Font.Size := Round( edt5.Font.Size *nuh);
...
我想定义一个过程,这样需要时直接调用一下过程即可
procedure Screen_Set(n:string);
var
nuw,nuh:Real;
begin
nuw:= Screen.Width / ScreenWidth;
nuh:= Screen.Height / ScreenHeight;
n.Width := Round( n.Width * nuw );
n.Left := Round( n.Left * nuw );
n.Height := Round( n.Height * nuh );
n.Top:=Round( n.Top * nuh);
n.Font.Size := Round( n.Font.Size *nuh);
end;
请问这里的n我应该定义成什么类型?或者应该怎么定义这样的一个函数?
edt3.Width := Round( edt3.Width * nuw );
edt3.Left := Round( edt3.Left * nuw );
edt3.Height := Round( edt3.Height * nuh );
edt3.Top:=Round( edt3.Top * nuh);
edt3.Font.Size := Round( edt3.Font.Size *nuh);
edt4.Width := Round( edt4.Width * nuw );
edt4.Left := Round( edt4.Left * nuw );
edt4.Height := Round( edt4.Height * nuh );
edt4.Top:=Round( edt4.Top * nuh);
edt4.Font.Size := Round( edt4.Font.Size *nuh);
edt5.Width := Round( edt5.Width * nuw );
edt5.Left := Round( edt5.Left * nuw );
edt5.Height := Round( edt5.Height * nuh );
edt5.Top:=Round( edt5.Top * nuh);
edt5.Font.Size := Round( edt5.Font.Size *nuh);
...
我想定义一个过程,这样需要时直接调用一下过程即可
procedure Screen_Set(n:string);
var
nuw,nuh:Real;
begin
nuw:= Screen.Width / ScreenWidth;
nuh:= Screen.Height / ScreenHeight;
n.Width := Round( n.Width * nuw );
n.Left := Round( n.Left * nuw );
n.Height := Round( n.Height * nuh );
n.Top:=Round( n.Top * nuh);
n.Font.Size := Round( n.Font.Size *nuh);
end;
请问这里的n我应该定义成什么类型?或者应该怎么定义这样的一个函数?
解决方案 »
- 帮我看下这段代码为何报错?
- 哪位大虾有TACMWaveIn音频控件,有弟急需!
- 为什么delphi7编译的程序在支持中文的英文操作系统下显示不出来中文,delphi5显示正常,delphi7是不是要设置什么?
- 如何按输入关键字搜索文本文件,将指针移至满足条件的行.
- 怎样用spcomm以字节接收数据
- 大家好,进来坐坐。我想求职
- 关于一个大学生是否违约的问题。请你关注。。。。。。。。。。。。
- 一个空件得到焦点的事件是什么,tks
- 创建一个临时的checkbox字段。
- 為什麼找來找去或者重新安裝都找不到SQL Builder,十萬火急!
- 求教,怎么让某个控件无法获得焦点?
- 求delphi插件,类似.net那样的,写个函数,会面会跟提示的,以前有用过,现在没有了
如果还要处理其他控件可以定义成TObjectprocedure Screen_Set(n:TObject);如果定义为TObject,则在procedure Screen_Set(n:TObject);
要对传入的参数进行类型判断和转换,之后在做相应的操作
type
TFooClass = class(TControl);//定义
.....
const
ScreenWidth:LongInt=1440 ; //当前显示器的值
ScreenHeight:LongInt=900 ; //当前显示器的值
.....
for i:=ControlCount-1 downto 0 do //循环改每个控件参数
begin
TFooClass(Controls).Font.Size:=Round(TFooClass(Controls).Font.Size*(Screen.Width/screenwidth));
TFooClass(Controls).Width:=Round(TFooClass(Controls).Width*(Screen.width/screenwidth));
TFooClass(Controls).Height:=Round(TFooClass(Controls).Height*(Screen.Height/screenheigh));
TFooClass(Controls).Left:=Round(TFooClass(Controls).Left*(Screen.Width/screenwidth));
TFooClass(Controls).Top:=Round(TFooClass(Controls).top*(Screen.Height/screenheigh));
end;
.....