Solved

Assigning Font to an Edit Control

Posted on 2006-07-24
9
211 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 111
matchUp  challenge 6 52
wait notify demo infinite loop 3 95
modThree challenge 4 76
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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…

914 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

14 Experts available now in Live!

Get 1:1 Help Now