Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is the proper call?
Message
General information
Forum:
Visual C++
Category:
ActiveX
Miscellaneous
Thread ID:
00805580
Message ID:
00807222
Views:
29
>>Once you have the handle to a window. What API can you use to get additional attributes about that window. I have GetClassName and GetWindowText they work great. I need to know additional info like does it have a border, min, max, close, titlebar and is it sizable ... etc.
>
>Joe,
>
>GetWindowLong(hWnd, GWL_STYLE) will help you. You can check returned window styles for presence of WS_BORDER, WS_CAPTION, WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_SIZEBOX styles.


If there is actually a .NET framework answer to this I am all
ears...

I have the window handle I am getting the consts from my
c++ header winuser.h. No matter what window I check I
always get the following;
1 max true
2 min False
3 HasBorder False
4 titlebar False

I have included the declaration and the functions below. I realize the code is VB.NET however I hope you can look past that and see if anything stands out in my application of GetWindowLong.
Private Declare Function GetWindowLong Lib "user32" 
Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex 
As Long) As Long
    Private Const WS_BORDER = &H800000
    Private Const WS_CAPTION = &HC00000                  
    Private Const WS_MAXIMIZEBOX = &H10000
    Private Const WS_MINIMIZEBOX = &H20000
    Private Const GWL_STYLE = (-16)

        Friend Function HasMax(ByVal hwnd As Long) As Boolean
        Dim Style As Long
        Style = GetWindowLong(hwnd, GWL_STYLE)
        If ((Style And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX) = True Then
            HasMax = True
        Else
            HasMax = False
        End If
    End Function

    Friend Function HasMin(ByVal hwnd As Long) As Boolean
        Dim Style As Long
        Style = GetWindowLong(hwnd, GWL_STYLE)
        If ((Style And WS_MINIMIZEBOX) = WS_MINIMIZEBOX) = True Then
            HasMin = True
        Else
            HasMin = False
        End If
    End Function

    Friend Function HasTitleBar(ByVal hwnd As Long) As Boolean
        Dim Style As Long
        Style = GetWindowLong(hwnd, GWL_STYLE)
        If ((Style And WS_DLGFRAME) = WS_DLGFRAME = True) Then
            HasTitleBar = True
        Else
            HasTitleBar = False
        End If
    End Function

    Friend Function HasBorder(ByVal hwnd As Long) As Boolean
        Dim Style As Long
        Style = GetWindowLong(hwnd, GWL_STYLE)
        If ((Style And WS_BORDER) = WS_BORDER = True) Then
            HasBorder = True
        Else
            HasBorder = False
        End If
    End Function
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform