我在窗体下部放了了两个按钮、一个picture控件、一个label控件,运行一下下面的程序:  
Private  Sub  Form_Load()  
 
Picture1.Move  0,  0  
Picture1.Height  =  (Label1(0).Height  +  5)  *  10  +  3  
Picture1.Width  =  (Label1(0).Width  +  5)  *  10  +  3  
Me.Height  =  Picture1.Height  +  900  
Me.Width  =  Picture1.Width  +  80  
Label1(0).Visible  =  False  
For  n  =  1  To  100  
i  =  (n  -  1)  \  10:  j  =  (n  -  1)  Mod  10:  Load  Label1(n)  
With  Label1(n)  
.Left  =  5  +  j  *  Label1(0).Width  
.Top  =  5  +  i  +  Label1(0).Height  
.Visible  =  True  
.Caption  =  n  
End  With  
Next  
 
End  Sub  
我本来想让按钮正好放在picture控件下的,现在因为窗体大小的改变它们的位置就不对了!得拉大窗体才看到了那两个按钮家伙~如何写程序让它们随窗体的变小也能放在原有的位置上呢?  
 
 

解决方案 »

  1.   


    Private Sub Form_Resize()
    Command1.Left = Form1.Width - Command1.Width - 500
    Command1.Top = Form1.Top + Command1.Height + 500End Sub
      

  2.   

    to qiqunet(暗黑神话)还是不行的~再帮偶看看吧
      

  3.   

    Private Sub Form_Resize()
    'Command1.Left = Form1.Width - Command1.Width - 500
    Command1.Top = picture1.Top + picture1.Height + 500End Sub
      

  4.   

    对于调节页面元素位置的代码放到Form_Resize中Private Sub Form_Resize()
    Dim x As Integer
    x = 100
    Command1.Left = x
    Command1.Top = Picture1.Top + Picture1.Height + 10
    Command2.Left = Command1.Left + Command1.Width + 100
    Command2.Top = Command1.Top
    End Sub还有如果一点要注意,对于容易控件注意ScaleWidth,Width和ScaleHeight,Height的区别
    比如Private Sub Form_Resize()Picture1.Move 0, 0, Form1.ScaleWidth / 2, Form1.ScaleHeight / 2
       Command1.Left = Form1.ScaleWidth - Picture1.Width - 20
       Command2.Left = Form1.Width - Picture1.Width - 20
       Command2.Top = Command1.Top + Command1.Height
    End Sub
      

  5.   

    Private Sub Form_Resize()
        Picture1.Move 10, 10, ScaleWidth - 10, ScaleHeight - 500
        Command1.Move ScaleWidth - Command1.Width - 60, Picture1.Top + Picture1.Height + 100
    End Sub
      

  6.   

    算好你的控件在放大后要放在那(与以前的位置相差多少)
    然后在resize事件中重画一下不就行了
      

  7.   

    在Resize过程中控制一下
    自己算一下位置咯