我做了一个MDI窗体,在菜单中选择后可弹出子窗体,但都是任意位置的显示,有没有什么方法让他固定位置显示,请帮我写出源代码并加点注释,我好举一反三,把每个子窗体都做掉,谢谢!

解决方案 »

  1.   

    在窗体load过程中使用Move方法
    MDIForm.Move left, top, width, heightleft 必需的。指定 MDIForm 左边的水平坐标 (x-轴)。 
    top 可选的。指定 MDIForm 顶边的垂直坐标 (y-轴)。  
    width 可选的。指定 MDIForm 新的宽度。 
    height 可选的。指定 MDIForm 新的高度。 
      

  2.   

    用代码设置窗体的top和left属性
      

  3.   

    楼主问题是子窗体,也一样:即设置父窗体的left, top, width, height;同时也设置子窗体的left, top, width, height。如MDIform1.move 0,0,200,200
    Form1.move 0,0,0,0
      

  4.   

    '*********************************************************
    '* 名称:FormSet(formname,mode)
    '* 功能:此函数用于初始化窗体的大小和位置
    '* 用法:mode 满屏(0),左上(1),右上(2),左下(3),右下(4),居中(5)
    '*********************************************************
    Public Function FormSet(F As Form, Nu As Integer) As String
        Dim BarHeight As Integer  '任务条的高度
        BarHeight = 27 * 15
        If IsNull(Nu) Then
            Nu = 0
        End If
        F.ScaleMode = 3 '将窗体的分辨率设为象素级
        Select Case Nu  '根据参数设置窗体的大小和位置
            Case 0          '默认的窗体效果,最大化
                With F
                    .top = 0
                    .Left = 0
                    .Width = Screen.Width
                    .Height = Screen.Height - BarHeight
                End With
            Case 1          '窗体的位置居左上
                With F
                    .top = 0
                    .Left = 0
                End With
            Case 2          '窗体的位置居右上
                With F
                    .top = 0
                    .Left = Screen.Width - .Width
                End With
            Case 3          '窗体的位置居左下
                With F
                    .top = Screen.Height - .Height - BarHeight
                    .Left = 0
                End With
            Case 4          '窗体的位置居右下
                With F
                    .top = Screen.Height - .Height - BarHeight
                    .Left = Screen.Width - .Width
                End With
            Case 5          '窗体的位置居中
                With F
                    .top = (Screen.Height - .Height) / 2
                    .Left = (Screen.Width - .Width) / 2
                End With
        End Select
        
    End Function
      

  5.   

    sub form_Load()
    me.top=
    me.left=
    end sub
      

  6.   

    lihonggen0(李洪根)的很好,佩服。
      

  7.   

    lihonggen0(李洪根)的答案写的挺好的