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:
00807304
Views:
42
This message has been marked as a message which has helped to the initial question of the thread.
>>>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

Joe, the following code works for me (VB6.0):
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_DLGFRAME = &H400000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const GWL_STYLE = (-16)

Private Sub Form_Load()
    Dim Style As Long
    Dim HasMax, HasMin, HasTitleBar, HasBorder As Boolean
    Style = GetWindowLong(hwnd, GWL_STYLE)
    HasMax = (Style And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX
    HasMin = (Style And WS_MINIMIZEBOX) = WS_MINIMIZEBOX
    HasTitleBar = (Style And WS_CAPTION) = WS_CAPTION
    HasBorder = (Style And (WS_BORDER Or WS_DLGFRAME)) <> 0
    Debug.Print HasMax, HasMin, HasTitleBar, HasBorder
End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform