Discussion:
How can I find out that window has WS_OVERLAPPED style
(too old to reply)
Yury
2005-10-04 12:18:01 UTC
Permalink
WS_OVERLAPPED==0. Is it true that all windows have WS_OVERLAPPED style.
William DePalo [MVP VC++]
2005-10-07 19:02:50 UTC
Permalink
IIs it true that all windows have WS_OVERLAPPED style.
No, definitely not.

You can check for the style like so:

if ( GetWindowLong(hWnd, GWL_STYLE) & WS_OVERLAPPED )
{
// Window has overlapped style
}

else
{
// It does not
}

Regards,
Will
Norman Bullen
2005-10-08 00:55:08 UTC
Permalink
Post by William DePalo [MVP VC++]
IIs it true that all windows have WS_OVERLAPPED style.
No, definitely not.
if ( GetWindowLong(hWnd, GWL_STYLE) & WS_OVERLAPPED )
{
// Window has overlapped style
}
else
{
// It does not
}
Regards,
Will
This will not work.

The value of WS_OVERLAPPED is 0x00000000L which, when combined with
anything using the bitwise AND operator, is still zero so the if
statement always takes the else branch.

Do this instead:
if ((GetWindowLong(hWnd, GWL_STYLE)&
(WS_POPUP|WS_CHILD))==0) {
// it is overlapped
}
else {
// it is not overlapped
}
(This assumes a valid window handle; an invalid handle will look like an
overlapped window.)

Norm
--
--
To reply, change domain to an adult feline.
William DePalo [MVP VC++]
2005-10-08 02:12:43 UTC
Permalink
Post by Norman Bullen
This will not work.
The value of WS_OVERLAPPED is 0x00000000L which, when combined with
anything using the bitwise AND operator, is still zero so the if statement
always takes the else branch.
Oops. Thanks for the correction.

Regards,
Will
Yury
2005-10-10 16:11:07 UTC
Permalink
Post by Norman Bullen
if ((GetWindowLong(hWnd, GWL_STYLE)&
(WS_POPUP|WS_CHILD))==0) {
// it is overlapped
}
else {
// it is not overlapped
}
(This assumes a valid window handle; an invalid handle will look like an
overlapped window.)
Norm
It is wrong. Microsoft Spy++ show that window this style 0x94c00880 has
WS_POPUP and WS_OVERLAPPED style.

Test.
1) Create window with style 0x94c00880.
2) Run “Microsoft Spy++”. And we see that window has WS_POPUP and
WS_OVERLAPPED styles.
3) Now run your code. And we see that window does not have a WS_OVERLAPPED
style.
Norman Bullen
2005-10-10 23:02:04 UTC
Permalink
Post by Yury
Post by Norman Bullen
if ((GetWindowLong(hWnd, GWL_STYLE)&
(WS_POPUP|WS_CHILD))==0) {
// it is overlapped
}
else {
// it is not overlapped
}
(This assumes a valid window handle; an invalid handle will look like an
overlapped window.)
Norm
It is wrong. Microsoft Spy++ show that window this style 0x94c00880 has
WS_POPUP and WS_OVERLAPPED style.
Test.
1) Create window with style 0x94c00880.
2) Run “Microsoft Spy++”. And we see that window has WS_POPUP and
WS_OVERLAPPED styles.
3) Now run your code. And we see that window does not have a WS_OVERLAPPED
style.
Actually, Microsoft Spy++ is wrong.

There are two bits in the window style that control its type. If the
high-order bit of the style DWORD is set, the window is a popup window.
If the next bit is set, the window is a child window. If neither is set,
the window is overlapped. (If both are set, the result is undocumented.)

Look at these definitions from WinUser.h.
#define WS_OVERLAPPED 0x00000000L
#define WS_POPUP 0x80000000L
#define WS_CHILD 0x40000000L

Your window style (0x94c00880) has the high-order bit set and the next
bit clear so it is a popup window, not an overlapped window.

The correct way to identify all three types of windows (this is what
Spy++ should do) is

dwStyle = GetWindowLong(hWnd, GWL_STYLE);
if (dwStyle&WS_POPUP) {
// it's a popup window
}
else if (dwStyle&WS_CHILD) {
// it's a child window
}
else {
// it's an overlapped window
}

Norm
--
--
To reply, change domain to an adult feline.
Loading...