OwnerDrawn Menu font problem 
Author Message
 OwnerDrawn Menu font problem

I'm implementing an owner-drawn menu.  Basically, I want the menu to look like a regular menu except I'm adding a list of subtext items below and indented from each menu item.  I have it working pretty well but I'm having trouble manipulating the fonts.  I want the subtext font to be a little smaller than the main text.

In MeasureItem I do the following to determine the size:

CDC* pdc = AfxGetMainWnd()->GetDC();

... GetTextExtent stuff for main text

CFont* pFont = pdc->GetCurrentFont();
LOGFONT lf;
pFont->GetLogFont(&lf);

lf.lfHeight-=1;
CFont fontSubText;
fontSubText.CreateFontIndirect(&lf);
pdc->SelectObject(&fontSubText);

... GetTextExtent stuff for sub text.

I do the same sort of stuff for the DrawItem function expect I get the DC as follows:

CDC dc;
dc.Attach(lpDIS->m_hDC);

Here's what I don't understand.  The font returned from GetCurrentFont in DrawItem is different from the one returned in MeasureItem.  It also has a negative lfHeight whose absolute value is smaller than the font from MeasureItem.

Can someone please explain to me what's going on?
Thanks much.



Tue, 16 Apr 2002 03:00:00 GMT  
 OwnerDrawn Menu font problem
The menu font is not the same thing as the window font. In MeasureItem, you
retreive the window font.
Check GetStockObject for stock fonts - DEFAULT_GUI_FONT gives the Win95 menu
font, for example.

You might also be interested in GetSystemMetrics(SM_CYMENU), which will
return the height of a menu line.

Johan Rosengren
Responsable Informatique
PACTA S.A.



I'm implementing an owner-drawn menu.  Basically, I want the menu to look
like a regular menu except I'm adding a list of subtext items below and
indented from each menu item.  I have it working pretty well but I'm having
trouble manipulating the fonts.  I want the subtext font to be a little
smaller than the main text.

In MeasureItem I do the following to determine the size:

CDC* pdc = AfxGetMainWnd()->GetDC();

... GetTextExtent stuff for main text

CFont* pFont = pdc->GetCurrentFont();
LOGFONT lf;
pFont->GetLogFont(&lf);

lf.lfHeight-=1;
CFont fontSubText;
fontSubText.CreateFontIndirect(&lf);
pdc->SelectObject(&fontSubText);

... GetTextExtent stuff for sub text.

I do the same sort of stuff for the DrawItem function expect I get the DC as
follows:

CDC dc;
dc.Attach(lpDIS->m_hDC);

Here's what I don't understand.  The font returned from GetCurrentFont in
DrawItem is different from the one returned in MeasureItem.  It also has a
negative lfHeight whose absolute value is smaller than the font from
MeasureItem.

Can someone please explain to me what's going on?
Thanks much.



Wed, 17 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OWNERDRAW ListBox: Problem with font in DC. Explanation?

2. OWNERDRAW ListBox: Problem with font in DC. Explanation?

3. CListCtrl ownerdraw font problem

4. OwnerDraw menu problems on Win95

5. Please help me with a ownerdraw menu problem!

6. ownerdrawn menu problems

7. OWNERDRAWN MENU PROBLEM

8. Need Help with OwnerDraw Menu, GetTextExtentPoint32 & Menu Fonts

9. Listcontrol ownerdraw mouse-sensitive font

10. Need Help with OwnerDraw Menu, GetTextExtentPoint32 & Menu Fonts

11. Ownerdraw context menu fails.

12. WTL - OwnerDrawn menus

 

 
Powered by phpBB® Forum Software