Native button with BS_AUTORADIOBUTTON style

How to get the status of a verified / unverified BS_AUTORADIOBUTTON? At the moment, my code is not working.

void CPngButton::DrawItem( LPDRAWITEMSTRUCT lpDIS )
{
    ASSERT(lpDIS != NULL);

    UINT state = lpDIS->itemState;
    if (state & ODS_CHECKED)
    {
    // do stuff
    }
}

I also tried

if (BST_CHECKED == SendMessage(BM_GETCHECK))

but it doesn’t work either.

+3
source share
2 answers

ODS_CHECKED applies only to menus. BM_GETCHECK and BM_GETSTATE can provide a verified state:

if (Button_GetState(lpDIS->hwndItem) & BST_CHECKED)
+4
source

According to the documentation , the flag is ODS_CHECKEDapplicable only to menu items:

ODS_CHECKED   This bit is set if the menu item should be checked. This bit is used only in the menu.

Instead, to determine the checked state of a button, you must call a function CButton::GetCheck. It will return one of the following values:

BST_UNCHECKED        

BST_CHECKED                            

BST_INDETERMINATE   ( BS_3STATE BS_AUTO3STATE).

:

CButton myBtn;
if (myBtn.GetCheck() = BST_CHECKED)
{
    // Drawing code here...
}
+1

Source: https://habr.com/ru/post/1793825/


All Articles