如何找出外部窗口的最顶层状态? [英] How do I find out the topmost state of an external window?

查看:87
本文介绍了如何找出外部窗口的最顶层状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定外部窗口的最顶层状态是否设置为true

How can I find out if an external window's topmost state is set to true

推荐答案

您可以使用 GetWindowLong 第二个参数 GWL_EXSTYLE

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v = vs.85).aspx [ ^ ]。



WS_EX_TOPMOST 的结果(实际的扩展样式),以查看有问题的窗口是否位于最顶层或n ot。



-SA
You can use GetWindowLong with second argument of GWL_EXSTYLE:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633584%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx[^].

AND the result (actual "extended style") with WS_EX_TOPMOST to see if the window in question topmost or not.

—SA


只想感谢所有帮助过的人。就在我即将放弃谢尔盖时,我指的是我昨天使用不正确的代码,只是为了今天取得成功:-)







Just want to say thanks to everybody who helped. Just when I was about to give up Sergey pointed me to code I used incorrectly yesterday, just to have success today :-)



Public Class Form1
    <DllImport("user32.dll", EntryPoint:="GetWindowLong")> _
    Private Shared Function GetWindowLongPtr32(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
    End Function

    <DllImport("user32.dll", EntryPoint:="GetWindowLongPtr")> _
    Private Shared Function GetWindowLongPtr64(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
    End Function

    ' This static method is required because Win32 does not support GetWindowLongPtr dirctly
    Public Shared Function GetWindowLongPtr(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
        If IntPtr.Size = 8 Then
            Return GetWindowLongPtr64(hWnd, nIndex)
        Else
            Return GetWindowLongPtr32(hWnd, nIndex)
        End If
    End Function
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'Dim notepad As Process = Process.GetProcessesByName("notepad")(0)
        'Dim hWnd As IntPtr = notepad.MainWindowHandle
        Dim GWL_EXSTYLE As Integer = -20
        Dim WS_EX_TOPMOST As IntPtr = 8
        'Dim Style As IntPtr = GetWindowLongPtr(hWnd, GWL_EXSTYLE)
        Dim notepad As Process = Process.GetProcessesByName("notepad")(0)
        Dim hWnd As IntPtr = notepad.MainWindowHandle
        Dim notepad2 As New HandleRef(0, hWnd)
        Dim Style As IntPtr = GetWindowLongPtr(notepad2, -20)
        MsgBox(Style.ToString)
    End Sub
End Class


检查 WS_EX_TOPMOST [ ^ ]。



您可以使用 EnumChildWindows [ ^ ]或 GetWindow [ ^ ]获取你要检查的窗口。
Check WS_EX_TOPMOST[^].

You can use EnumChildWindows [^] or GetWindow [^] to get the window you want to check.


这篇关于如何找出外部窗口的最顶层状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆