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"
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
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)的变化!
错了一点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 这样对了
哦Private Const WS_EX_TOPMOST = &H8&
to: Chice_wxg 有个疑问:某个活动窗口上面没有其他窗口覆盖,用你的代码判断却是NotTopMost。 我的目的只是想判断一个窗口上面是否有其他窗口覆盖,并不一定要是TopMost。
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"
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
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)的变化!
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
这样对了
有个疑问:某个活动窗口上面没有其他窗口覆盖,用你的代码判断却是NotTopMost。
我的目的只是想判断一个窗口上面是否有其他窗口覆盖,并不一定要是TopMost。