Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to change the fontsize of a dialog control edit box, but it just bold the font of edit box and does not change the size of font and font style but the same code works with the static control why? The Code are that:-
CWnd* pWnd = GetDlgItem(IDC_EDIT1);
CFont font;
font.CreateFont(20,10,0,1,700,0,0,0,0,0,0,0,0,"Arial");
pWnd->SetFont(&font);

The same code with static control works
CWnd* pWnd = GetDlgItem(IDC_STATIC);
CFont font;
font.CreateFont(20,10,0,1,700,0,0,0,0,0,0,0,0,"Arial");
pWnd->SetFont(&font);

Please Any one can help me...:rose:
Posted
Updated 22-Jan-10 9:13am
v2

Are you aware of (MSDN):
For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a specified point size:

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);

?
If, for instance, your mapping mode is MM_TEXT (the default), and the LOGPIXELSY value is 96, then you have to specify -27 (circa) as nHeight parameter (the first one of CreateFont) to obtain a 20-pixels height font.
:)
 
Share this answer
 
v3
I think you need to tell the edit control via the WM_SETFONT message. More information may be found here[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900