How to use bitmap for a three state check box with OBM_CHECKBOXES.

Rahul Mendke 1 Reputation point
2020-07-29T02:13:21.537+00:00

Hello,
I want to use three state checkbox in the list control. Today, there is facility for normal checkbox. The bitmap for normal check box are loaded from OBM_CHECKBOXES.
The problem is, I am not able to find the bitmap image for intermediate state (CBS_MIXEDNORMAL). Could anyone help which image index I can use for intermediate state using OBM_CHECKBOXES.

Thanks,
Rahul M

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,493 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rita Han - MSFT 2,161 Reputation points
    2020-08-05T07:03:13.803+00:00

    Hello,

    I am not able to find the bitmap image for intermediate state (CBS_MIXEDNORMAL)

    That is a non-themed bitmap. If you want a themed bitmap, you have to use the DrawThemeBackground to draw it to create a bitmap.

    There are two bitmaps may be used for intermediate state:

    One is CBS_MIXEDNORMAL. DrawThemeBackground(theme, hdc, BP_CHECKBOX, CBS_MIXEDNORMAL, &rc, nullptr);

    15716-20200805-2.png

    Another is CBS_CHECKEDDISABLED. DrawThemeBackground(theme, hdc, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rc, nullptr);

    15695-20200805-3.png

    Code sample as below:

    HDC hdc = BeginPaint(hWnd, &ps);  
    HTHEME theme = OpenThemeData(nullptr, L"Button");  
      
    RECT rc = {};  
    rc.right = 12;  
    rc.bottom = 12;  
    DrawThemeBackground(theme, hdc, BP_CHECKBOX, CBS_MIXEDNORMAL, &rc, nullptr);  
      
    CloseThemeData(theme);  
      
    EndPaint(hWnd, &ps);  
    

    Thank you!

    0 comments No comments