Solved

Ownerdraw combobox item height

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 198
zeroMAx challenge 20 101
EvenOdd challenge 10 108
Making an alias 7 95
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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