Solved

Assigning Font to an Edit Control

Posted on 2006-07-24
9
215 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 125 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
Technology Partners: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
font missing in acrobat 3 77
x-bar in Google Sheets 2 91
Problem to Office 1 39
How to change fonts in windows live mail 3 17
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…

713 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