我的问题是:
怎样使窗体上的控件如button、panel等,在窗体最大化时仍然保持未最大化时相对于窗体的位置,而不是缩到窗体的一角。请大家快帮助我!!!!!!!!!

解决方案 »

  1.   

    按钮的属性anchors,你更改为你需要的就好了。
      

  2.   

    你可以得到窗体的top,left值,得到button或panel的top,left值。它们的和应该就是button相对与屏幕的top,left,记下来.在窗体大小改变是,改变button的left,和top为先前记录的left,top.
      

  3.   

    left,top,width,heigh
    就这几个参数就可以了
      

  4.   

    设置anchor,根据需要选择left,top,botton,right中的一个或多个
      

  5.   

    讲的不够明白。
    你可以在窗体的resize的事件里添加一些代码。比如:
    //相对左上角不移动
    button.Left := 100;  // 根据你想把按钮放到的位置进行修改
    Button.Top  := 100;  // 
    // 相对右下角,位置不移动
    Panel1.Left := Width - 100;  // 具体的数值根据你设计的界面进行修改
    Panel1.Top  := Height - 100;
      

  6.   

    我没把问题说清楚,我的意思是我的窗体上的panel等控件,根据窗体的变大也变大。
    这该怎么弄?
      

  7.   

    在窗体的 Resize 事件中处理吧
      

  8.   

    给你一点源代码
    动态的改变窗体。
    用Delphi编写DLL实现动态改变分辨率 
    西安海星系统集成中心 
    田俊国 
    ---- 读了贵刊发表的《在VB中调用API函数动态改变及恢复屏幕设置》一文,觉得非常实用。的确,因显示器的分辩率的不一致而影响软件界面及人机正常交互的情形太多了。通常,我们的应用可能用VB、Delphi、PB等不同语言实现的,如果在各种语言中都调用API来实现动态的变屏幕设置的话,先不管调用能否成功,光一个DEVMODE结构在不同语言的定义就需要半天。能不能自己做一个DLL,装封几个简单的动态改变屏幕分辨率的函数,以达到不同语言均可调用的目的呢?作者进行了一番探索。Delphi语言封装大部分Windows API函数,只要在uses子句后加上 Windows,即可直接调用许多Windows API函数。因此笔者选用Delphi语言。 ---- 一、创建一个DLL ---- 关于在Delphi中如何创建DLL,已有不少文章介绍过了,读者也可以在Delphi5.0的帮助中查找(有详细例子),在此不再赘述。Setscn.dll中装封了三个函数: ---- setdisplaymode函数实现动态设置屏幕分辩率,参数pwidth、pheight为欲设置分辩率的屏宽和屏高,返回值为longint型,为0表示成功。 ---- getscreenwidth()函数的功能是取得当前屏幕的屏宽,返回值为longint型。 ---- getscreenwidth()函数的功能是取得当前屏幕的屏高,返回值为longint型。 ---- 程序源代码如下: library  setscn;
    uses Windows;
    var NewDevMode: TDEVMODE;
    function setdisplaymode(pwidth,pheight:integer):
    longint;stdcall;export;
    begin
       With NewDevMode do
       begin
          dmSize := 122;
          dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT ;
          dmPelsWidth := pwidth ;
          dmPelsHeight := pheight ;
       end;
      result:=ChangeDisplaySettings(NewDevMode,0);
    end;
    Function getscreenwidth():longint;stdcall;export;
    begin
    result:=GetDeviceCaps(hinstance, HORZRES);
    end;
    function getscreenheight():longint;stdcall;export;
    begin
    result:=GetDeviceCaps(hinstance, VERTSIZE);
    end;
      exports
      setdisplaymode index 1,
      getscreenwidth index 2,
      getscreenheight index 3;
      begin
      end.
    ---- 编译以上代码,生成一个名为setscn.dll的动态连接库,将其拷贝到windows的system目录下,便大功告成。 
    ---- 二、为setscn创建引入程序单元 ---- 为了在Delphi语言中成功调用上述函数,我们需要编写以下引入程序单元。 {Import unit for setscn.Dll}
    unit scnimport;
    interface
    function setdisplaymode(pwidth,pheight:integer):longint;
    function getscreenwidth():longint;
    function getscreenheight():longint;
    implementation
    function setdisplaymode(pwidth,pheight:integer):longint;
    external 'setscn' index 1;
    function getscreenwidth():longint;external 'setscn' index 2;
    function getscreenheight():longint;external 'setscn' index 3;
    end.
    ---- 三、不同语言中的声明及调用: 
    ---- 1、 VB中声明及调用: ---- VB中声明: Private Declare Function setdisplaymode Lib 
    "setscn.dll" (ByVal pwidth As Integer, ByVal 
    pheight As Integer) As Long
    Private Declare Function getscreenwidth Lib 
    "setscn.dll" () As Long
    Private Declare Function getscreenheight Lib
     "setscn.dll" () As Long
    Dim sh, sw As Long
    ---- 调用示例:点击Command1将屏幕分辩率设为640*480,点击Command2恢复原来设置。 
    Private Sub Command1_Click()
    sw = getscreenwidth()
    sh = getscreenheight()
    setdisplaymode 640, 480
    End Sub
    Private Sub Command2_Click()
    setdisplaymode sw, sh
    End Sub
    ---- 2、PB中声明及调用: 
    ---- PB中声明: Public Function long setdisplaymode(long pwidth, 
     long pheight)Library " setscn.dll"
    Public Function long getscreenwidth()Library 
    " setscn.dll"
    Public Function long getscreenheight()Library
     " setscn.dll"
    ---- 调用示例:点击cb_1将屏幕分辩率设为640*480,点击cb_2恢复原来设置。如下: 
    //clicked for cb_1 return long
    //sw、sh是long型的全程变量
    sw=getscreenwidth()
    sh=getscreenheight()
    setdisplaymode(640,480)
    //clicked for cb_2 return long
    setdisplaymode(sw,sh)
    ---- 3、Delphi中的声名及调用 
    ---- 因为我们为setscn创建引入程序单元scnimport.pas,所以只要在uses子句后添加上scnimport,即可直接调用(源代码略)。 
      

  9.   

    因为Anchor属性决定是否在父窗体位置固定的,是一个集合,有Top等个选相! 要解jayelva2003 (allen)  问题,只要把组件的Anchor属性的个选相都设置为True,就行了