Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a Font

Status
Not open for further replies.

zulfi1234

Instructor
Jul 2, 2000
32
PK
I am trying to select a Font from CFontDialog but its not working. Can somebody plz help me ?

I am using following code:

CFontDialog dlgChooseFont;

if( dlgChooseFont.DoModal() == IDOK)
{

if(!ptrlogfont) ptrlogfont = new LOGFONT;
memcpy(ptrlogfont, &(dlgChooseFont.m_lf), sizeof(LOGFONT));
fontcolor = dlgChooseFont.GetColor();
hfont = CreateFontIndirect(ptrlogfont);
ptreditwin->SendMessage(WM_SETFONT, (UINT) hfont, 0L);
}

Zulfi
 
If You use the selected Font in MFC CRichEditView (or it's child), You can write in any child Class of CRichEditView:
CFontDialog dlg(m_charformat, CF_BOTH|CF_NOOEMFONTS);
if (dlg.DoModal() == IDOK)
{
dlg.GetCharFormat(m_charformat);
SetCharFormat(m_charformat);
}
else
return;
where m_charformat - a Member of CRichEditView.
If not - You have more to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top