Style, ExStyle and ClassStyle are just 32-bit numbers right. And each setting (WS_BORDER for example) is one bit. And if that bit is a 1, than that setting is enabled, right? If thats true i could just use GetWindowLong and then check each bit to see if its enabled, right? I think i use "and" for that......... right?
Posted on 2002-03-30 18:51:02 by ChimpFace9000
Right.
Posted on 2002-03-30 19:49:58 by The Svin
Is there any easy way to tell which bit is which setting?
Posted on 2002-03-30 21:37:54 by ChimpFace9000
push GWL_STYLE
push hWnd
call GetWindowLong
test eax, WS_BORDER
jne @F
...
@@:test eax, WS_DLGFRAME
jne @F
...
Posted on 2002-03-31 00:15:08 by bdjames
Use bitwise AND.

* Set the bits you want to test for truth to 1 and all the
others to 0
* apply the AND operator to the value in question
* check for truth; 1 = true, 0 = false

Say we have a value A and we wish to test if its second bit is set:
A = 10101010b
B = 00000000b
C = 00000010b

A and B = 0 (false) -- because 1 AND 0 = 0
A and C = 1 (true) -- because 1 AND 1 = 1

Cheers,
Boggy
Posted on 2002-03-31 00:15:49 by Boggy
FYI, the TEST instruction preforms the AND operation, setting
the flags based on the result and not effecting the registers.
Posted on 2002-03-31 00:31:14 by bitRAKE
There's at least one exception to the one-style-one-bit rule.

WS_OVERLAPPED, WS_POPUP, and WS_CHILD are encoded in a two-bit field. The value of WS_OVERLAPPED is 0, which means if you don't mention any of the three styles, you'll get the WS_OVERLAPPED style. You'll need to check the definition of these constants to see where the two-bit field is.
Posted on 2002-04-01 15:52:59 by tenkey
tenkey I'm not following you. What do you mean by "two-bit field"? At first I
thought you meant a value that is encoded with two-bits but re-reading your
question you don't seem to be implying that (how does 0 encode to two-bits?!).
Posted on 2002-04-01 23:05:27 by Boggy
0 is the equate value, and the two-bit field contains binary 00 as a result.
Posted on 2002-04-02 12:00:26 by tenkey

0 is the equate value, and the two-bit field contains binary 00 as a result.


WS_OVERLAPPED is the default window style, it is defined as 0x00000000L and
hence in the absence of any other window style it becomes the default; symbolically
it has no use other than being a reminder. Why on earth would you need to test
its value?

And how do WS_POPUP, and WS_CHILD relate to this? They can be tested by using
any of the methods others have stated previously in this thread.
Posted on 2002-04-02 21:00:56 by Boggy
There are three extended styles which are slightly different in much the way Tenkey was saying.

WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR.

These three styles are 00h so they cannot be directly tested for through bit patterns in the way you suggest (to my knowledge).

If you need to determine these styles I would test for the negation of its opposite. Such as (not WS_EX_RIGHT) and so forth. ;)
Posted on 2002-04-03 09:07:33 by Graebel

These three styles are 00h so they cannot be directly tested for through bit patterns in the way you suggest (to my knowledge).

If you need to determine these styles I would test for the negation of its opposite. Such as (not WS_EX_RIGHT) and so forth.


Did you read my post carefully? My point was this: there is no need to
check for default values.


Allow me to re-iterate.

If you read the API documentation you'll find that (among others) WS_EX_LEFT,
WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR, and WS_OVERLAPPED are all default
window styles--they are defined as all-bits-zero for this very reason.

If you already know that a Window is given the WS_EX_LEFT style by default,
you would simply test for WS_EX_RIGHT; if your test returns true then your
window as right-aligned properties, OTHERWISE it has the default WS_EX_LEFT
(all-bits-zero) style.

See what I'm trying to get at?
Posted on 2002-04-03 16:42:51 by Boggy