PRB: Font Changes as ActiveX Control Resizes (191126)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q191126 SYMPTOMS
When you call SelectStockFont() to select a Stock font property to display
text in an ActiveX control, the font of the text changes as the size of the
control changes with SetWindowPos() or MoveWindow().
CAUSE
SelectStockFont() selects a scaled font into a device context. This causes
the font size to change as the control resizes. However, the natural extent
is not changed (m_rcBounds is bigger but m_cyExtent is not). As a result,
the stock font doesn't scale perfectly with respect to the size of the
control.
RESOLUTION
Here are two possible workarounds for this problem: - Use SetControlSize() instead of SetWindowPos() or MoveWindow() to change
the size of the control.
- Replace SelectStockFont() with the following code:
CFontHolder& fntHolder =InternalGetFont();
HFONT internalhFont = fntHolder.GetFontHandle();
HFONT hOldFont = (HFONT)::SelectObject(pdc->m_hDC,internalhFont);
pdc->TextOut(20, 20, "Hello", 5);
::SelectObject(pdc->m_hDC,hOldFont);
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 12/1/2003 |
---|
Keywords: | kbprb KB191126 |
---|
|