3

I'm playing around with drawing my own custom controls using the uxTheme library in Windows, and I can't work out why my control doesn't look like the regular Windows control that (supposedly) uses the same theme I'm using:

A Windows ComboBox and my control that uses the ComboBox theme

The above image shows a standard Windows ComboBox (top) and my custom control drawn using the ComboBox theme (bottom). What I can't work out is why the border from my control is a different shape and colour to the standard control.

In my class constructor I open the theme data:

mComboTheme = OpenThemeData( hwnd, L"COMBOBOX" );

And then in the handler for WM_PAINT I'm just drawing two parts of the ComboBox components:

case WM_PAINT:
{
    PAINTSTRUCT ps;
    HDC         hdc;
    RECT        client;

    if( GetUpdateRect( hwnd, &ps.rcPaint, false ))
    {
        hdc = BeginPaint( hwnd, &ps );
        GetClientRect( hwnd, &client );

        if( IsThemeBackgroundPartiallyTransparent( mComboTheme, CP_BACKGROUND, CBXS_HOT ))
        {
            DrawThemeParentBackground( hwnd, hdc, &ps.rcPaint );
        }
        DrawThemeBackground( mComboTheme, hdc, CP_BACKGROUND, CBXS_HOT, &client, &ps.rcPaint );
        client.left = client.right - 20;
        DrawThemeBackground( mComboTheme, hdc, CP_DROPDOWNBUTTONRIGHT, CBXSR_HOT, &client, ps.rcPaint );

        EndPaint( *this, &ps );
    }
    break;
}

Any suggestions as to why these two controls don't look the same would be greatly appreciated.

Thanks,

James

skaffman
  • 398,947
  • 96
  • 818
  • 769

1 Answers1

4

You called DrawThemeBackground with CP_BACKGROUND and CP_DROPDOWNBUTTONRIGHT. Perhaps you should also call it with CP_BORDER if you want the border to match the standard combobox?

Jon
  • 3,065
  • 1
  • 19
  • 29
  • Hah! Yes, that was the rather obvious point I was missing. Thanks. :) –  Mar 11 '11 at 19:31