I would like to use raw winapi32 to check button style whether it is a checkbox button or a pushbutton.
bool isPushBtn(HWND hBtn, DWORD dwStyle)
{
return (0!=dwStyle | GetWindowLong(hBtn,GWL_STYLE));
}
But this always returns false. Do you know a way to check this ? Thank you.
In order to understand how button styles work we need to look at the values used by the style constants:
The other essential reference is the Button Styles topic at MSDN. However, what that document does not explain is that the
BS_PUSHBUTTONtoBS_OWNERDRAWflags, the type flags, are mutually exclusive. The other flags can be used in combination with one of the type flags. This can be inferred from the bit patterns of the values.The documentation for
BS_TYPEMASKstates:However I think this is misleading and endorse what ybungalobill said in his answer. No harm can come of following that advice.
In other words you should mask the style with
BS_TYPEMASKand then test for a particular button type.