If Screen.ActiveForm.Name ="UrFrmName" then
   True
End if

解决方案 »

  1.   


    Private Sub Form_Load()
        If GetWindowLong(hwnd, GWL_EXSTYLE) & 8 = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
        SetWindowPos Me.hwnd, -1, 0, 0, 100, 100, 0
        If (GetWindowLong(hwnd, GWL_EXSTYLE) And 8) = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
      

  2.   


    Private Sub Form_Load()
        If GetWindowLong(hwnd, GWL_EXSTYLE) & 8 = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
        SetWindowPos Me.hwnd, -1, 0, 0, 100, 100, 0
        If (GetWindowLong(hwnd, GWL_EXSTYLE) And 8) = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
    End Sub
      

  3.   


    Private Sub Form_Load()
        If GetWindowLong(hwnd, GWL_EXSTYLE) & 8 = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
        SetWindowPos Me.hwnd, -1, 0, 0, 100, 100, 0
        If (GetWindowLong(hwnd, GWL_EXSTYLE) And 8) = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
    End Sub
    注意GetWindowLong(hwnd, GWL_EXSTYLE)的变化!
      

  4.   

    错了一点Private Sub Form_Load()
        If (GetWindowLong(hwnd, GWL_EXSTYLE) And 8) = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
        SetWindowPos Me.hwnd, -1, 0, 0, 100, 100, 0
        If (GetWindowLong(hwnd, GWL_EXSTYLE) And 8) = 8 Then Debug.Print "TopMost" Else Debug.Print "NotTopMost"
    End Sub
    这样对了
      

  5.   

    哦Private Const WS_EX_TOPMOST = &H8&
      

  6.   

    to: Chice_wxg
    有个疑问:某个活动窗口上面没有其他窗口覆盖,用你的代码判断却是NotTopMost。
    我的目的只是想判断一个窗口上面是否有其他窗口覆盖,并不一定要是TopMost。