如果一个VB程序里面有两个form,怎么让其中一个form永远置于另一个的上面。

解决方案 »

  1.   

    上层窗体作为下层窗体的子窗体就行了.设上层窗体为FormA,下层为FormB,则在B中作如下调用即可:FormA.Show ,Me
      

  2.   

    你用模式窗口弹出来说行了
    前边的窗口不关闭,后面的永远也出不来
    form2.show 1
      

  3.   

    这个是你需要的吗?Private Const HWND_TOPMOST = -1
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Sub Command1_Click()
    Dim x As New Form2
    x.Show
    End SubPrivate Sub Form_Load()
    Dim lStyle As Long, b As Long
    With Me
            SetWindowPos .hwnd, HWND_TOPMOST, (Screen.Width - .Width) / 2 / Screen.TwipsPerPixelX, (Screen.Height - .Height) / 2 / Screen.TwipsPerPixelY, .Width / Screen.TwipsPerPixelX, .Height / Screen.TwipsPerPixelY, 0
    End With
    End Sub
      

  4.   

    模式化显示要置顶的Form即可。
      

  5.   

    就是稍微有点闪烁'在每个窗体都添加这个
    Private Sub Form_Activate()
    showForm1
    End Sub
    '公共模块里么的
    Sub showForm1()
    Dim x As Form
    For Each x In Forms
            x.ZOrder 1
    Next
    Form1.ZOrder 0
    End Sub