如何让一个窗体显示在其他程序前面,但在其子窗体(用Show(1)方法显示的子窗体)后面。

解决方案 »

  1.   

    Const HWND_TOP = 0
    Const SWP_NOSIZE = &H1
    Const SWP_NOZORDER = &H4
    Const SWP_NOMOVE = &H2
    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()
        Call SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
    End SubPrivate Sub Command1_Click()
        Form2.Show 1
        Call SetWindowPos(Form2.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
    End Sub
      

  2.   

    楼主是说Always TOPMOST窗体吗?模式窗体是不能总在最顶端的吧~