我在1024*768的分辨率下开发的程序,放到800*600的机器上却显示不完窗体,若在
800*600下开发,则在1024*768下不能全屏,很是苦恼,各位帮帮忙。

解决方案 »

  1.   

    不同分辨率下的屏幕控制:procedure TForm1.FormCreate(Sender: TObject);
    const
      ScreenWidth: LongInt = 800; {在800*600下开发的界面.}
      ScreenHeight: LongInt = 600;
    begin
      scaled := true;
      if (screen.width <> ScreenWidth) then
      begin
        height := longint(height) * longint(screen.height) div ScreenHeight;
        width := longint(width) * longint(screen.width) div ScreenWidth;
        scaleBy(screen.width, ScreenWidth);
      end;end;
      

  2.   

    假設你在1024*780的分辨率下的form,第一步:
    inplementation
    const
      ScreenWidth: LongInt = 1024; {I designed my form in 800x600 mode.}
      ScreenHeight: LongInt = 780;{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
      scaled := true;
      if (screen.width <> ScreenWidth) then
      begin
        height := longint(height) * longint(screen.height) div ScreenHeight;
        width := longint(width) * longint(screen.width) div ScreenWidth;
        scaleBy(screen.width, ScreenWidth);
      end;
    end;下一步,要讓每個子控制的字体改到合适的大小:
    type
      TFooClass = class(TControl); { needed to get at protected }
                                   { font property }var
      i: integer;
    begin
      for i := ControlCount - 1 downto 0 do
        TFooClass(Controls[i]).Font.Size :=
            (NewFormWidth div OldFormWidth) *
            TFooClass(Controls[i]).Font.Size;
    end;
      

  3.   

    分辨率的问题
    不同的分辨率下原来的窗口界面可能变得面目全非,对于这种问题,我一般采取以下方式: 
    先取得分辨率方法有如下: 
    procedure TForm1.FormCreate(Sender: TObject); 
    var 
    sx,sy:Integer; 
    begin 
    sx := GetSystemMetrics(SM_CXSCREEN); //分辨率宽 
    sy := GetSystemMetrics(SM_CYSCREEN); //分辨率高 
    end; 
    也可以用Screen.width/Screen.Height来取得 
    也可以用Var DevMode:TDeviceMode; 
    Begin 
    EnumDisplaySettings(nil,0,DevMode)  
    sx := DevMode.dmPelsWidth  
    sy := DevMode.dmPelsHeight 来取得 
    end 
    也可以用sx := GetDeviceCaps(GetDC(Form1.Handle), HORZRES) 
    sx :=GetDeviceCaps(GetDC(Form1.Handle), VERTRES) 来取得而后有以下几种方法:
    1. 判断分辨率并选择相应的分辨率方案; 
    (对每种分辨率设计一套控件/字体的大小方案用于在不同分辨率下选择)
    2. 固定窗口大小; 
    procedure TForm1.FormResize(Sender: TObject); 
    begin 
    width:=640; height:=480; 
    left:=0; top:=0; 
    end; 
    3. 使用procedure ScaleBy(M, D: Integer)这个过程来对可视控件进行大小调节(此过程不调节窗口大小,也不变动控件的left和top,对控件的大小按M/D比例来调节),具体如下: 
    procedure TForm1.FormCreate(Sender: TObject); 
    //假设原来的设计环境为800x600 
    var FWidth:integer; 
    begin 
    if(Screen.width<> 800)then 
    begin 
    FWidth:=Width; 
    Scaled:=TRUE; 
    Font.Size:=(Width DIV FWidth)*Font.Size;//字体大小调整 
    ScaleBy(Screen.Width,800); //控件大小调整 
    Height:=longint(Height)*longint(Screen.Height)DIV 600;  
    Width:=longint(Width)*longint(Screen.Width)DIV 800;//窗口大小调整 
    end; 
    end; 
    用此种方法比较实用,而且使用比较简单,基本能适应大多数环境。 4. 调节分辨率到所需的分辨率(即设计时的分辨率,此法对要求封闭的系统比较有用,如工控、触摸屏等等) 
    procedure TForm1.FormCreate(Sender: TObject); 
    var   FWidth:integer; 
    DevMode:TDeviceMode; 
    begin 
    if(Screen.width<> 800)then 
    begin 
          Result:=EnumDisplaySettings(nil,0,DevMode); //取得旧的显示参数 
          if Result then 
          begin 
            DevMode.dmFields:=DM_PELSWIDTH Or DM_PELSHEIGHT; 
             DevMode.dmPelsWidth:=800; 
            DevMode.dmPelsHeight:=600; 
    ChangeDisplaySettings(DevMode,0); //设置新的显示参数 
    end; 
    end; 
    end;
    5. 设置控件的Align和Anchors属性
      

  4.   

    copy 别人的东西;你用过没有,好用吗?看了到不错,你用的好吗?推荐你使用:Anchors属性,将其设置为[akTop,akLeft,akBottom,akRight]
    Anchors属性指的是你所使用的可视化控件距离窗体边缘的值是否固定;
    例如:akTop=True,表示离窗体top固定配合Align属性的AlClient尤其的爽,多试一试,常用panel
      

  5.   

    楼上:
    我当然用过!
    你的方法可以解决800*600下不能完全显示1024*768的界面吗?CSDN是提供一个帮助别人和获得帮助的渠道,不是比高低的地方!
      

  6.   

    我觉得ChangeScale比ScaleBy好用。另外为了严谨,最好能响应WM_DISPLAYCHANGE消息.
      

  7.   

    如果是在800*600下做界面,在窗口Create事件: 
    ScaleBy(Screen.Width, 800);