Solved

Ownerdraw combobox item height

Posted on 1998-07-24
3
742 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
3 Comments
 

Expert Comment

by:sheeba021198
Comment Utility
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
Comment Utility
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
Comment Utility
Try this:
SetItemHeight ( -1, tm.tmHeight + 2);
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Looking for a specific application/software 2 91
iSeries DB2 Query 2 82
fizzArray2 challenge 1 55
EvenOdd challenge 10 81
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now