Solved

Assigning Font to an Edit Control

Posted on 2006-07-24
9
210 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
Comment Utility
you may use CEdit::SetFont() for this purpose.
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 125 total points
Comment Utility
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
Comment Utility
>>>> 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 22

Expert Comment

by:mahesh1402
Comment Utility
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
Comment Utility
read above as m_font.CreateFontIndirect( &lf );
0
 
LVL 1

Expert Comment

by:yogesh28577
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now