Discussion:
Drop-down list with CBS_DROPDOWNLIST | CBS_OWNERDRAWVARIABLE in Vista
(too old to reply)
Arno
2007-02-13 10:43:45 UTC
Permalink
Hello,

my application contains some editable comboboxes and some fixed drop-
downs, and users complain that it is hard to tell them apart. Luckily,
Microsoft realized this ancient UI shortcoming and finally made them
distinct in Vista. Yet, when using the CBS_OWNERDRAWVARIABLE style,
Vista reverts to the old white field + arrow style. How can I create
owner-drawn combo boxes that have the new drop-down style?

TIA,

Arno
James Brown
2007-02-13 17:53:01 UTC
Permalink
Post by Arno
Hello,
my application contains some editable comboboxes and some fixed drop-
downs, and users complain that it is hard to tell them apart. Luckily,
Microsoft realized this ancient UI shortcoming and finally made them
distinct in Vista. Yet, when using the CBS_OWNERDRAWVARIABLE style,
Vista reverts to the old white field + arrow style. How can I create
owner-drawn combo boxes that have the new drop-down style?
TIA,
Arno
You will have to draw the combobox manually, using the DrawThemeBackground
API as appropriate.
--
James Brown
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Tutorials and Sourcecode
Jeffrey Tan[MSFT]
2007-02-14 06:25:24 UTC
Permalink
Hi Arno,

Yes, in Vista, the different background colors between CBS_DROPDOWNLIST and
CBS_DROPDOWN are drawn by the Vista theme. If you switch the theme back to
the classic theme on Vista, you will find that they will still draw the
same background color.

I agree with James that you should use DrawThemeBackground API to render
the new Vista theme(including Aero Visual Style). Ensure your user
interface is correctly using the Windows Vista common controls(ComCtl32
v6).

The article below demonstrats how to use DrawThemeBackground to draw XP
theme, however, the idea is similar to the Vista theme:
"Add XP Visual Style Support to OWNERDRAW Controls"
http://www.codeproject.com/w2k/xpvisualstyle.asp
"Rendering standard Windows elements"
http://blogs.msdn.com/oldnewthing/archive/2005/08/01/445998.aspx

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Arno
2007-02-19 11:57:27 UTC
Permalink
Thank you for your answers. I played around with DrawThemeBackground a
bit before. As far as I understand, it basically draws a bitmap-
defined rectangle, no more magic there, in particular no animation.

I subclassed the WM_PAINT message of a combo box, and it seems to do
most of the drawing. But it does not get called terribly frequently,
at least not frequently enough to render the smooth blend-in and blend-
out of the Vista button activations. How is that done? Do I have to
code all this myself, or is there a more elegant (and hopefully more
compatible with future Windows versions) way to do it?

Thanks for your help,

Arno
Jeffrey Tan[MSFT]
2007-02-20 09:50:45 UTC
Permalink
Hi Arno,

Thanks for your feedback.

I will try to consult Windows Shell team to get more information regarding
this topic. I will get back to you ASAP. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT]
2007-02-22 06:06:48 UTC
Permalink
Hi Arno,

Sorry for the late response, I am out of office at home yesterday.

By discussing this issue with the Vista shell team, I was told that the
comctl32 combobox uses DrawThemeBackground to draw its various image states
and uses the buffered paint APIs (look at BeginBufferedPaint) to smoothly
transition between any two states. Both of these are documented on MSDN

Because you specified an owner drawn combo box, you are on the hook to
paint everything yourself. Do note that a of the sequencing and timing are
non accessible semantics, so your simulation may not be 100% accurate. You
could also run into issues down the road with the next version of Windows
where further semantics may be incorporated into the combo box and your
custom versions may be out of place.

You could try subclassing a normal combobox and avoid all of this.

Can you tell me what are you trying to do that is not possible with
combobox or comboboxex?

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Arno
2007-02-22 11:41:15 UTC
Permalink
Hello Jeffrey,

thanks for your response. I looked at the BeginBufferedAnimation/Paint
API, and found this Swing bug

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6435825

where people have apparently run into a similar problem. They
apparently coded everything themselves, which I would like to avoid if
at all possible.

I am currently using a standard combobox to choose fonts of various
sizes. The combobox is not editable, so it has the CBS_DROPDOWNLIST
style, which usually results in a "button" instead of a "edit field
+little button" look in Vista. But to show fonts of various sizes, I
have to paint the combobox items myself. So I use the
CBS_OWNERDRAWVARIABLE style. But with this style, presumably for
compatibility, Vista reverts to the "edit field+little button" look.
This last behaviour I would like to override.

If I don't use the CBS_OWNERDRAWVARIABLE style, custom-painting combo-
box items is difficult, in particular because my items have variable
height (otherwise inserting empty strings and painting on top of them
myself would still no be elegant, but easier). Thus I don't quite
understand what you mean by "subclassing a normal combobox and avoid
all of this".

Thanks for all your help,

Arno
Jeffrey Tan[MSFT]
2007-02-26 05:50:52 UTC
Permalink
Hi Arno,

Sorry for the late response.

I have tried to forward your concern and comment to that shell developer.
He said he did not have all the answers for this question and recommended
another developer who is more familiar with combobox. However, the
recommended guy still did not provide any further information yet.

Due to the complexity of this issue, it is not efficient to support this
issue through newsgroup support. I would recommend you contact Microsoft
PSS for a case support for this issue. PSS support has official channel to
contact the product dev team, so I am sure they will provide better support
on it.

You can contact Microsoft Product Support directly to discuss additional
support options you may have available, by contacting us at 1-(800)936-5800
or by choosing one of the options listed at
http://www.microsoft.com/services/microsoftservices/srv_support.mspx

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jeffrey Tan[MSFT]
2007-02-27 06:05:45 UTC
Permalink
Hi Arno,

I finally got feedback from the current Combobox developer, below is his
comment:

"For compatibility comboboxes with ownerdraw style fallback to old painting
code and they look similarly to XP. In such case there is no "button" look
for CBS_DROPDOWNLIST.

I would leave ownerdraw style to paint content of drop-down listbox in
WM_DRAWITEM handler as it is done currently.

To have this new "button" look for CBS_DROPDOWNLIST your user has to
subclass combobox (http://msdn2.microsoft.com/en-us/library/ms997565.aspx)
and handle WM_PAINT message. Then he has to paint combobox himself using
DrawThemeBackground and BeginBufferedAnimation in WM_PAINT handler. This is
not easy and there is no guarantee that it will work in next version of
Windows but unfortunately there is no better way now :("

So it seems that there is a dark area without perfect solution. Microsoft
PSS may have some better solution.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Arno
2007-02-27 07:37:54 UTC
Permalink
Thanks a lot for your research!

Arno
g***@stayinfront.com
2007-03-01 02:11:35 UTC
Permalink
I just wanted to add my two cents worth. This is a really bad bit of
design from Microsoft. The developer's excuse that the XP look was
retained 'For compatibility...' is just laziness. There is no good
reason why the CS_DROPDOWNLIST | CS_OWNERDRAW* boxes couldn't use the
frame style of the standard CS_DROPDOWNLIST, and put the owner-draw
stuff inside. Sure, there might be some work for us to handle the
different way of showing the focus, but that would be minor and
handled entirely within WM_DRAWITEM. No non-trivial app is going to
look great under Vista without some work, anyway.

Telling us to subclass and paint it ourselves is appalling.

Grant.
Arno
2007-03-08 12:43:21 UTC
Permalink
Hello Jeffrey,

I have drawn the Combobox as your programmer has suggested by
subclassing WM_PAINT.

However, outside WM_PAINT, inside WM_LBUTTONDOWN, WM_SETFOCUS draws a
white background. Some web search revealed that there is also painting
happening inside WM_KILLFOCUS. To prevent this drawing, I could
subclass WM_SETFOCUS/KILLFOCUS and not call the default
implementation. Is this acceptable or would this break the combobox
somehow? How else would I customize the drawing?

Thanks in advance,

Arno
Jeffrey Tan[MSFT]
2007-03-09 09:43:05 UTC
Permalink
Hi Arno,

Since we have no official channel to ask the UI/Shell team for support, it
is rude for me to strike them again and again. So if you really need a
ideal solution, I would recommend you to contact Microsoft PSS, they may
provide more professional support over this(since they can submit formal
request to the dev team).

Personally, I agree that your solution should work. If the white background
is drawnd by the default WM_KILLFOCUS handler, you may filter the message
by using subclassing.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
n***@winvoice.com
2007-05-02 13:47:58 UTC
Permalink
I don't suppose there was any final code that came out of all of
this? I've subclassed a ComboBox in C# and am getting the same white
background under Vista.

public class TestComboBox : ComboBox
{

public TestComboBox()
{
this.DrawMode = DrawMode.OwnerDrawFixed;
this.DrawItem += new
DrawItemEventHandler(TestComboBox_DrawItem);
}
void TestComboBox_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
// don't even care about text, my icon, or anything else at this
point, just want the background to work.
}
}

Loading...