winapiwindow-style

How to check if a window style exists in a hexadecimal?


I have a question regarding a window style hexadecimal.

According to http://support.microsoft.com/kb/111011/en-us, 0x16CF0000 contains window styles of WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.

How do I check if a window style exist in a combination of window styles? For example, I would like to check if WS_BORDER (0x00800000) style exists in 0x16CF0000.


Solution

  • The standard form with my bug fixed is:

    if ((value & WS_BORDER) != 0) {  }
    

    The & will do a bitwise-AND and only if the bit of WS_BORDER is set will the result be non-zero