Solved

Ownerdraw combobox item height

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 54
notReplace  challenge 53 141
Smart Camera scanning and reading information 3 113
building a service to accessed via telnet client, want colors ? 4 92
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 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