对于代码
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我应该定义成什么类型?或者应该怎么定义这样的一个函数?

解决方案 »

  1.   

    如果你的自定义过程只是想对TEdit进行操作,那就把n定义成TEditprocedure Screen_Set(n:TEdit);
    如果还要处理其他控件可以定义成TObjectprocedure Screen_Set(n:TObject);如果定义为TObject,则在procedure Screen_Set(n:TObject);
    要对传入的参数进行类型判断和转换,之后在做相应的操作
      

  2.   

    已解决
    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; 
    .....