Itemheight for ownerdrawn ListBox
Mats Mеnhav -- manhav@connectum.skurup.se Friday, April 19, 1996 -- [ From: Mats Manhav * EMC.Ver #2.5.02 ] -- ENV: Win NT/95 MSVC 4.1 Hi, I am creating an ownerdrawn listbox class that is derived from CListBox. I want most of the drawing in the dialog box to be exactly like a standard ListBox. The standard ListBox has an item height of 13, but when I make it OwnerDrawn the default item height is 19. How do I retrieve the correct value to use. I thought GetSystemMetrics() a good candidate, but could not find an index fitting for a ListBox height. Mats -- ========================================================================== Mats Mеnhav (Mats Manhav for 7-bit people) email:manhav@connectum.skurup.se WWW: http://connectum.skurup.se/~manhav FAX: (int) 46 (0) 414 243 05 Phone: (int) 46 (0) 414 243 05 ==========================================================================
Willie Lyons -- willie@ccohs.ca Monday, April 22, 1996 [Mini-digest: 2 responses] Mats Manhav wrote: > > ENV: Win NT/95 MSVC 4.1 > Hi, > I am creating an ownerdrawn listbox class that is derived from > CListBox. > > I want most of the drawing in the dialog box to be exactly like a > standard ListBox. > The standard ListBox has an item height of 13, but when I make it > OwnerDrawn the default item height is 19. How do I retrieve the > correct value to use. > I thought GetSystemMetrics() a good candidate, but could not find an > > index fitting for a ListBox height. > In the past I have used GetItemHeight on a normal listbox and SetItemHeight on the ownerdraw listbox within WM_INITDIALOG. You could also just SetItemHeight with a value of 13 if you have no normal listbox from which to get the standard item height. -----From: Don.Irvine@net-tel.co.uk You need to process the WM_MEASUREITEM message returning the height passed on the font selected in the listbox. The following code works for me: void CConfigDlg::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct) { if( nIDCtl != -1 ) { CFont* pFont = GetFont(); if(pFont != NULL) { CWindowDC dc(this); CFont* pOldFont = dc.SelectObject( pFont ); TEXTMETRIC tm; dc.GetTextMetrics( &tm ); lpMeasureItemStruct->itemHeight = tm.tmExternalLeading + tm.tmHeight; dc.SelectObject( pOldFont ); } } } Don
| Вернуться в корень Архива |