Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

font size limit 1

Status
Not open for further replies.

serpem

Programmer
Feb 20, 2003
22
US
I used the following code to implement a font menu in my program:
CFont m_font;
void CTestFormView::OnViewFont()
{
CFontDialog dlgChooseFont;
if(dlgChooseFont.DoModal() == IDOK)
{
m_font.DeleteObject();
m_font.CreateFontIndirect(
dlgChooseFont.m_cf.lpLogFont);
}
}
the problem is that text spills out of the drawing area when the user selects a font size beyond 14. how can I implement a font menu that limit the font size available?
 
0) there are many fonts, with many sizes (widths). Limiting the font size alone will not solve your problem.
1) see if you can clip the displayed text using GetTextExtent() and the width of the area used to display the text
2) You can probably rule out obviously wrong font sizes (e.g. 20 or above) by examining lpLogFont members.
 
I can't really do 1) because the text does'nt make anymore sense if it is clipped. my best option now is 2). but is there any way I can disable or remove the fonts and font sizes I don't want from the Choose Font Dialog Box?
 
Perhaps you can dump the output into an uneditable text field with scroll bars. It would be relatively painless.
 
that may be interresting. I am writing the texts on a FormView with different fields (within group boxes), so I am not sure how to go about that.
 
I'm pretty new to the MFC, so I can't say too much, but I know that if you are using something like EDITTEXT, you can initialize it with ES_MULTILINE | WS_VSCROLL, etc.

Maybe worth checking into, anyway.
 
I tried it with ES_MULTILINE | WS_VSCROLL |READ_ONLY and it works just fine. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top