
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.