When writing code for owner-draw
combo boxes try to keep these guidelines:
Use SetItemData, because it easy to
get it with the DRAWITEMSTRUCT without making any obsolete and
time consuming function calls.
Check the state
and action of the item to
know when to draw selection rectangles. Check for the state
ODS_SELECTED, and ODA_SELECT to handle this case.
Find a way to
know when the control has focus, and make the control
show it. The focus is better passed as a parameter to
the drawing functions. This will be a better logic. Come
up with a different logic if you have some different types of
handling them.
Remember to
return the old device context settings if you have changed
them. If you don?t weird things
might happen. This is one of the most important things to
be done as advised by Microsoft.
Try to avoid
copy-pasting code when
writing combo and list boxes with similar interface. Implement
a single class which can be called for drawing the interface.