Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to draw a custom control that should use the "combobox" theme class.

Using
C++
m_hTheme = OpenThemeData(m_hWnd, _T("COMBOBOX"));
    auto stateBG = ...; // depends on window state
    DrawThemeBackground(m_hTheme, ps.hdc, CP_READONLY, stateBG, &clientRect, nullptr);

gives the correct background (read-only-look) without the chevron. But how do I add the chevron?
C++
auto stateCV = ...; // depends on window state
    DrawThemeBackground(m_hTheme, ps.hdc, CP_DROPDOWNBUTTON, stateCV, &rect, nullptr);

draws the chevron correctly, but with its own border and the chevron centered within the `rect`. So if I use the full client rect, I get this:
combobox centered chevron[^]

If I use a smaller rect so that the chevron is positioned correctly, I get a separated dropdown:
combobox boxed chevron[^]

How do I get the "normal" look? - i.e like this:
How it should look[^]

Is there any documentation that does a better job than MSDN? It's as sparse as most newer documentation, e.g. just listing "Parts and States", without describing their purpose (which is not always obvious), and whether it's `DrawThemeBackground` or ~`Edge`for a particular item.

Bonus Question: Do I still use the good old `DrawFocusRect`for the focus rect?

What I have tried:

(see above. I've tried a lot. like really a lot. 30 chatracters you say?)
Posted
Updated 29-Nov-20 21:29pm
v2
Comments
Rick York 30-Nov-20 3:24am    
All three links point to the same image.
peterchen 30-Nov-20 3:30am    
oops, fixed!
[no name] 30-Nov-20 12:22pm    
Can't you just position a chevron anywhere? In another "layer" if that makes any sense. A GUI is not "real"; it's all dots.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900