Jump to content

find out a window's styles?


Sven
 Share

Recommended Posts

I made this function 4 years ago:

I know, it could be done better now.

BTW: Open Watcom C - C++ Compiler has a nice Spy onboard showing all sytles and more. And it's is freeware.

#include <Constants.au3>
#include <WindowsConstants.au3>

Global $sActiveWindow = WinGetTitle("")
Global $aStyle = _WinGetStyle(WinGetHandle($sActiveWindow))

MsgBox(0, $sActiveWindow & " - Styles", _WinStyle2Text($aStyle[0]))
MsgBox(0, $sActiveWindow & " - ExStyles", _WinExStyle2Text($aStyle[1]))

Func _WinStyle2Text($iStyle)
    ; funkey
    Local $sReturn
    Local $aStyles[27][2] = [['$WS_OVERLAPPEDWINDOW', BitOR($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_THICKFRAME, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)], _
                ['$WS_POPUPWINDOW' , BitOR($WS_POPUP, $WS_BORDER, $WS_SYSMENU)], _
                ['$WS_POPUP'       , 0x80000000], _
                ['$WS_CHILD'       , 0x40000000], _
                ['$WS_MINIMIZE'    , 0x20000000], _
                ['$WS_VISIBLE'     , 0x10000000], _
                ['$WS_DISABLED'    , 0x08000000], _
                ['$WS_CLIPSIBLINGS', 0x04000000], _
                ['$WS_CLIPCHILDREN', 0x02000000], _
                ['$WS_MAXIMIZE'    , 0x01000000], _
                ['$WS_CAPTION'     , 0x00C00000], _
                ['$WS_BORDER'      , 0x00800000], _
                ['$WS_DLGFRAME'    , 0x00400000], _
                ['$WS_VSCROLL'     , 0x00200000], _
                ['$WS_HSCROLL'     , 0x00100000], _
                ['$WS_SYSMENU'     , 0x00080000], _
                ['$WS_THICKFRAME'  , 0x00040000], _
                ['$WS_GROUP'       , 0x00020000], _
                ['$WS_TABSTOP'     , 0x00010000], _
                ['$WS_MINIMIZEBOX' , 0x00020000], _
                ['$WS_MAXIMIZEBOX' , 0x00010000]]
;~                ['$WS_TILED'       , $WS_OVERLAPPED], _
;~                ['$WS_ICONIC'      , $WS_MINIMIZE], _
;~                ['$WS_SIZEBOX'     , $WS_THICKFRAME], _
;~                ['$WS_CHILDWINDOW' , $WS_CHILD], _
;~                ['$WS_TILEDWINDOW' , $WS_OVERLAPPEDWINDOW]]
;~                 ['$WS_OVERLAPPED'  , 0x00000000], _
    For $i = 0 To UBound($aStyles, 1) - 1
        If BitAND($iStyle, $aStyles[$i][1]) = $aStyles[$i][1] Then
            $sReturn &= $aStyles[$i][0] & @CRLF
            $iStyle = BitXOR($iStyle, $aStyles[$i][1])
        EndIf
    Next
    Return $sReturn & @CRLF & 'Unknown: 0x'& Hex($iStyle, 8)
EndFunc   ;==>_WinStyle2Text

Func _WinExStyle2Text($iExStyle)
    ; funkey
    Local $sReturn
    Local $aExStyles[27][2] = [['$WS_EX_OVERLAPPEDWINDOW', BitOR($WS_EX_WINDOWEDGE,$WS_EX_CLIENTEDGE)], _
                    ['$WS_EX_PALETTEWINDOW'   , BitOR($WS_EX_WINDOWEDGE, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)], _
                    ['$WS_EX_DLGMODALFRAME'  , 0x00000001], _
                    ['$WS_EX_DRAGDETECT'     , 0x00000002], _
                    ['$WS_EX_NOPARENTNOTIFY' , 0x00000004], _
                    ['$WS_EX_TOPMOST'        , 0x00000008], _
                    ['$WS_EX_ACCEPTFILES'    , 0x00000010], _
                    ['$WS_EX_TRANSPARENT'    , 0x00000020], _
                    ['$WS_EX_MDICHILD'       , 0x00000040], _
                    ['$WS_EX_TOOLWINDOW'     , 0x00000080], _
                    ['$WS_EX_WINDOWEDGE'     , 0x00000100], _
                    ['$WS_EX_CLIENTEDGE'     , 0x00000200], _
                    ['$WS_EX_CONTEXTHELP'    , 0x00000400], _
                    ['$WS_EX_RIGHT'          , 0x00001000], _
                    ['$WS_EX_LEFT'           , 0x00000000], _
                    ['$WS_EX_RTLREADING'     , 0x00002000], _
                    ['$WS_EX_LTRREADING'     , 0x00000000], _
                    ['$WS_EX_LEFTSCROLLBAR'  , 0x00004000], _
                    ['$WS_EX_RIGHTSCROLLBAR' , 0x00000000], _
                    ['$WS_EX_CONTROLPARENT'  , 0x00010000], _
                    ['$WS_EX_STATICEDGE'     , 0x00020000], _
                    ['$WS_EX_APPWINDOW'      , 0x00040000], _
                    ['$WS_EX_LAYERED'        , 0x00080000], _
                    ['$WS_EX_NOINHERITLAYOUT', 0x00100000], _
                    ['$WS_EX_LAYOUTRTL'      , 0x00400000], _
                    ['$WS_EX_COMPOSITED'     , 0x02000000], _
                    ['$WS_EX_NOACTIVATE'     , 0x08000000]]

    For $i = 0 To UBound($aExStyles, 1) - 1
        If BitAND($iExStyle, $aExStyles[$i][1]) = $aExStyles[$i][1] Then
            $sReturn &= $aExStyles[$i][0] & @CRLF
            $iExStyle = BitXOR($iExStyle, $aExStyles[$i][1])
        EndIf
    Next
    Return $sReturn & @CRLF & 'Unknown: 0x'& Hex($iExStyle, 8)
EndFunc   ;==>_WinExStyle2Text

Func _WinGetStyle($WinTitle, $WinText = "")
    ; modified by funkey
    Local $RetValue[2], $Temp, $h_window

    $h_window = $WinTitle
    If Not IsHWnd($h_window) Then
        $h_window = WinGetHandle($WinTitle, $WinText)
        If @error Then Return SetError(1, 0, "")
    EndIf

    ; read Windowstyle
    $Temp = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $h_window, "long", $GWL_STYLE)
    If @error Then SetError(2, 0, "")
    $RetValue[0] = '0x' & StringFormat('%008s', Hex($Temp[0]))

    ; read extended Windowstyle
    $Temp = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $h_window, "long", $GWL_EXSTYLE)
    If @error Then SetError(3, 0, "")
    $RetValue[1] = '0x' & StringFormat('%008s', Hex($Temp[0]))
    Return $RetValue
EndFunc   ;==>_WinGetStyle

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...