如何让窗口显示在主界面窗体前面

解决方案 »

  1.   

    http://www.codesky.net/article/list.asp?id=3067&showcomment=1
      

  2.   

    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 Form_Load()
        SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    End Sub
      

  3.   

    在窗体2里面加入: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 Form_Load()
        SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    End Sub
      

  4.   

    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 Form_Load()
        SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
    End Sub
      

  5.   

    Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Private Sub Timer1_Timer()
    Dim s As Long
    s = GetForegroundWindow()
    If s <> Me.hwnd Then
    SetForegroundWindow Me.hwnd
    End If
    End Sub
      

  6.   

    你可以这样一来试试:(个人意见)
    'Form2:
    private sub cmd_Search_click()
       '其他代码
       dim frmForm3 as Form3
       set frmForm3 =new Form3
       frmForm3.show vbModal
       '其他代码
    end sub
    这样一来的话,Form3总在Form2之前,并且你关闭Form3时,Form2不会消失.
      

  7.   

    要么就关闭3的时候,
    form1.hide
    form3.hide
    form2.show
      

  8.   

    'Form2:
    private sub cmd_Search_click()
       '其他代码
       dim frmForm3 as Form3
       set frmForm3 =new Form3
       frmForm3.show 1,form2   '设为模式窗体
       '其他代码
    end sub