Detecting window styles with bitwise-and
Posted: 22 Feb 2018, 12:02
Hello
I was wondering how it is that bitwise-and is able to detect combinations of window styles. For example the style 0xC00000 (WS_CAPTION) is derived from the addition of 0x800000 (WS_BORDER) and 0x400000 (WS_DLGFRAME) and the documentation seems to suggest it could be detected by:
It seems like this would throw a false positive if the window happened to have a different style where just one of the bits happened to be equal to one of the bits in 0xC00000, since the bitwise-and would evaluate to a non-zero number and therefore true. Does Microsoft encode the window styles in such a way that happens to avoid this? I can't seem to find the answer on MSDN or actually anywhere. Or does the above method only work for single styles and not combinations? Should I do two bitwise-and checks, one for each style?
Thanks
I was wondering how it is that bitwise-and is able to detect combinations of window styles. For example the style 0xC00000 (WS_CAPTION) is derived from the addition of 0x800000 (WS_BORDER) and 0x400000 (WS_DLGFRAME) and the documentation seems to suggest it could be detected by:
Code: Select all
If (StyleToCheck & 0xC00000)
Thanks