Solved

Assigning Font to an Edit Control

Posted on 2006-07-24
9
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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…

615 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