Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Assigning Font to an Edit Control

Posted on 2006-07-24
9
Medium Priority
?
225 Views
Last Modified: 2013-12-03
hi,
I am doing a text editor using Win32 programming, I am creating a Edit control at run time, the text editor is taking some default font. I am not able to assign a font called "Nudi-10" to that Edit control.Can any body help me in this regard.....

Thanks in advance,
Prathibha
0
Comment
Question by:sree032397
  • 4
9 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17166686
you may use CEdit::SetFont() for this purpose.
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 total points
ID: 17166698
e.g.

CFont m_font; //make this global

//On Init
m_font.CreatePointFont(200, _T ("Nudi-10"));

pEditCtrl->SetFont (&m_font, TRUE); //set font for edit control

-MAHESH
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 17170226
>>>> CFont m_font; //make this global

Better make it a member of your dialog class.

"Nudi-10" needs to be the name of an existing font. The name should be spelled exactly like you see it in the font combo box of the dialog resource properties.

>>>> m_font.CreatePointFont(200, _T ("Nudi-10"));

Note, the first argument is the required point size times 10. That means you create a 20 points font by the statement.

Regards, Alex
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:mahesh1402
ID: 17173616
yeah right as said by itsmeandnobodyelse  'CreatePointFont' requires 'Font Face Name' which is full font name..

You may also use LOGFONT struct for this

CFont m_font;

LOGFONT lf;
ZeroMemory( &lf, sizoef( lf ) );
lstrcpy( lf.lfFaceName, _T("courier") ); // assign whatever font face name you want to

lf.lfHeight = 30;       // assign font height you may also assign font width with lf.lfWidth ( both in logical units )

font.CreateFontIndirect( &lf );

pEditCtrl->SetFont( &font );

-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17173620
read above as m_font.CreateFontIndirect( &lf );
0
 
LVL 1

Expert Comment

by:yogesh28577
ID: 17434755
NONCLIENTMETRICS ncm;
  ncm.cbSize=sizeof(NONCLIENTMETRICS);
  SystemParametersInfo(SPI_GETNONCLIENTMETRICS,0,&ncm,0);
    ncm.lfStatusFont.lfHeight=15;
  ncm.lfStatusFont.lfWeight=FW_NORMAL ;
  strcpy(ncm.lfStatusFont.lfFaceName,"Arail");
  Font.CreateFontIndirect(&ncm.lfStatusFont);    
edit1.SetFont(&Font,TRUE);
edit1 is memeber variable of editbox
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question