separate function that is called from the OnInitDialog().
It all woks fine. Thanks for your help. One quick question concerning
fine. I don't have it encapsulated with an if...statement.
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
Several things wrong with this...see below...
On Sat, 28 Aug 2010 17:22:01 -0500, "JCO" <someone@somewhere.com> wrote:
Thanks... this is what I added below:
CFont font;
****
Note that this must be declared in a scope that lives as long as the edit
control. If you
declare it as a local variable, the font will be destroyed when the
variable goes out of
scope, and the control will not be able to use it.
****
LOGFONT lf;
memset( &lf, 0, sizeof(LOGFONT) ); lf.lfHeight
****
If you want to create a LOGFONT, you could write
LOGFONT lf = {0};
and the compiler will zero it out. I presume there is some obscure reason
you wrote two
statements on one line; that is exceedingly poor style.
****
= 12; _tcsncpy_s(lf.lfFaceName,
LF_FACESIZE,_T("Arial"), 7);
****
THis is absolutely silly. DId you notice that the string "Arial" has FIVE
characters? Why
did you write "7" for the length? It would have made sense to have
written
_tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"));
but not to use _tcscpy_n with an erroneous length.
****
VERIFY( font.CreateFontIndirect(&lf) );
pParent->c_editResults.SetFont( &font );
pParent->c_editResults.SetWindowTextW( strResults );
****
Note that you only want to create one font and set it once, not each time
you change the
contents. You did not say where this code is taking place; if it is
OnInitDialog, that is
OK, sort of, but you still have to create the font variable in the class,
in the same
place the CEdit control is declared.
*****
//send results to control on parent dialog & use new font
font.DeleteObject();
****
And this, of coursse, is insane. You have told the control to use the
font, then you
delete the very font you told it to use! How do you expect it to use the
font if you've
just deleted it?
****
However, I'm displaying in a multi-line EditBox. So when you look at
4-displayed lines, they are scrunched together. I can correct this by
formatting with an extra "\n" at 3-locations (4-lines of text) but I'm not
sure that is the best way to make it look more readable.
****
An edit control uses \r\n to indicate end-of-line.
joe
****
Thanks
"ScottMcP [MVP]" <scottmcp@mvps.org> wrote in message
news:b0a6f067-576e-4456-ae07-3abdea05bef2@f6g2000yqa.googlegroups.com...
On Aug 28, 5:11 pm, "JCO" <some...@somewhere.com> wrote:
VC 2008, MFC
How easy is it to change the text size that is displayed in an EditBox?
I
just want to make it more readable by sizing up the text. I currently
format the words using CString. Then I send it to the EditBox for
display
as shown below:
Code:------------------------------------
CString strResults ( _T("") );
strResults.Format( ....................................... );
c_editResults.SetWindowTextW( strResults );
Thanks
Very easy. Use CreateFontIndirect to initialize a CFont member
variable. Call c_editResults.SetFont with it.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm