Link to home
Start Free TrialLog in
Avatar of tflex
tflex

asked on

Ownerdraw combobox item height

If combobox or listbox is defined as fixed ownerdraw, height of its items is changed by MFC.  I am doing the following thing for getting back normal size. But may be there is more simple or elegant solution.

  CClientDC dc(this);
  CFont* pOldFont = dc.SelectObject(GetFont());
  TEXTMETRIC tm;
  VERIFY (dc.GetTextMetrics ( &tm ));
   SetItemHeight (0, tm.tmHeight + 2);
Avatar of sheeba021198
sheeba021198

u have to override the MeasureItem function of CComboBox for eg:
void CColorListBox::MeasureItem(LPMEASUREITEMSTRUCT lpMIS)
{
      // all items are of fixed size
      // must use LBS_OWNERDRAWVARIABLE for this to work
      lpMIS->itemHeight = COLOR_ITEM_HEIGHT  ;
      
}
I think this is what u needed
Avatar of tflex

ASKER

Sheeba,

1. What is COLOR_ITEM_HEIGHT?
I want the height to be exactly the same size like non-ownerdrawn item.

2. My ComboBox is not  LBS_OWNERDRAWVARIABLE. It is fixed.
ASKER CERTIFIED SOLUTION
Avatar of timop
timop

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial