子窗口名为frmAbout,在它的load事件中用:
frmAbout.Left = ((1 / 2) * (Screen.Width - frmAbout.Width))
frmAbout.Top =  ((1 / 2) * (Screen.Height - frmAbout.Height))
显示的位置不对。
谢谢

解决方案 »

  1.   

    frmAbout.Left = (Screen.ScaleWidth - frmAbout.Width)/2
    frmAbout.Top =  (Screen.ScaleHeight - frmAbout.Height)/2
      

  2.   

    frmAbout.Left = (Screen.ScaleWidth - frmAbout.Width)/2
    frmAbout.Top =  (Screen.ScaleHeight - frmAbout.Height)/2
      

  3.   

    设置窗体的StartUpPosition属性为2--屏幕中心
      

  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.   

    子窗口?是MDI子窗体吧窗口的坐标系是基于父窗口的
    只有顶层窗口的坐标与屏幕坐标一致
      

  6.   

    就是MDI子窗体kmzs(.:RNPA:.山水岿濛) 的方法不行,Screen没有ScaleWidth属性lihonggen0(李洪根,MS MVP,标准答案来了)因为是MDI子窗体,所以您的方法也不行
      

  7.   

    最多只能再顶一次。
    这个问题应该是MDI经常碰到的啊。
    如果有同样问题的伙伴请帮我也顶一下。
      

  8.   

    '***********************************************************************
    '* 函數名稱: centerwindow
    '* 函數用途: 窗口置中函數
    '* 參數說明: p_Form As FROM,p_MDIFORM As MDIForm
    '*           p_Form 要居中的子窗體,p_MDIFORM父窗體名
    '* 注意: 應先加載你窗體,否則子窗體的位置可能會不正確
    '**********************************************************************
    Sub CenterWindow(p_Form As Form,P_MdiForm As MDIForm)
        '把表單置中
        If p_Form.Width > P_MdiForm.ScaleWidth Then
            p_Form.Left = 0
        Else
            p_Form.Left = (P_MdiForm.ScaleWidth - p_Form.Width) / 2
        End If    If p_Form.Height > P_MdiForm.ScaleHeight Then
            p_Form.Top = 0
        Else
            p_Form.Top = (P_MdiForm.ScaleHeight - p_Form.Height) / 2
        End If
      
     End Sub
      

  9.   

    不太懂,WindowPositon属性应该可以解决问题
    代码实现也没太大问题,不知楼主为何会出现这种问题
      

  10.   

    先显示,后再设置居中.frmAbout.SHOW
    frmAbout.Left = (Screen.Width - frmAbout.Width)/2
    frmAbout.Top =  (Screen.Height - frmAbout.Height)/2
      

  11.   

    是MDI的!!
      我也有这个问题,顺便也来取取经,我就没怎么设置啦,怎么把子窗口出来时也搞成最大化的呢?? :(
      

  12.   

    CatchWind() 的办法好。
    我都已经不抱任何希望了,居然还能解决。
    谢谢
      

  13.   

    请教CatchWind() :
    P_MdiForm.ScaleWidth为什么用ScaleWidth
    而p_Form.Width却用width?
      

  14.   

    因為父窗體是作為子窗體的容器,所以要用內部有效寬度.
    相應地,如果你在子窗體上放置一個文本框,希望它与窗體寬度一致,也要用子窗體的ScaleWidth屬性.具體的你可以參考MSDN.