Solved

Ownerdraw combobox item height

Posted on 1998-07-24
3
813 Views
Last Modified: 2013-11-20
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);
0
Comment
Question by:tflex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:sheeba021198
ID: 1319698
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
0
 

Author Comment

by:tflex
ID: 1319699
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.
0
 
LVL 1

Accepted Solution

by:
timop earned 50 total points
ID: 1319700
Try this:
SetItemHeight ( -1, tm.tmHeight + 2);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question