Link to home
Start Free TrialLog in
Avatar of cmain
cmain

asked on

Setting Font in CEdit

Hi,

I am having trouble setting the font for a CEdit.
void someroutine( );
{
  CFont fnt;
  fnt.CreatePointFont( 100, "Times New Roman" );
  setfont( &fnt );
}

void setfont( CFont* fnt )
{
  m_Edit.SetFont( &fnt )
}

The trouble is that the control does not seem to redraw correctly.

I have tried m_Edit.InvalidateRect( NULL ), which also does not help.

I have changed the m_Edit to an m_pEdit (CEdit*) and re-created the edit control then set the font, and this also doesn't work, which I find *very* odd.

The font does change, but if you make it bigger than the current font, the cursor size is small and the individual lines in the CEdit are drawn very squashed, covering each other. The cursor also looks to narrow for the height of the text?

Please note that I am using a property sheet.
Each property sheet has an edit control on it, and some must be proportional fonts, and others not.

I don't get it.


Regards
-craig.
ASKER CERTIFIED SOLUTION
Avatar of bobbym
bobbym

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I agree with BobbyM,

You could also add the font pointer to your header file and create the fonts during the constructor of the property sheet.  Then within the OnSetActive of each page, then call

m_Edit.SetFont( m_fntProportional );

Then you only have to create the fonts once and use them whenever you need to.

Make sure you delete them in the destructor!  

Phillip

Avatar of cmain
cmain

ASKER

Your answer was right on the button (no pun intended).
Do you know if there are docs on when to use the detach methods?
Thankx

Hmmm whenerver you need it :)). Well genereally whenever you need to disconnect the relationship between the C++ object and the Windows object that's it. Sorry I do not know about any docs.