OVH Cloud OVH Cloud

GetFont() me retourne NULL?

5 réponses
Avatar
Jean-Claude
Bonjour...MFC, 2000
j'essaye désespérément de changer le charset de mon CRichEdit. Je fais:

LOGFONT structFont1;

structFont1.lfHeight=m_nHeight-2;
structFont1.lfWidth=m_nWidth;
structFont1.lfEscapement=0;
structFont1.lfOrientation=0;
structFont1.lfWeight=m_nWeight;
structFont1.lfItalic=m_bItalic;
structFont1.lfUnderline=m_bUnderline;
structFont1.lfStrikeOut=m_bStrikeOut;
structFont1.lfCharSet=RUSSIAN_CHARSET;
structFont1.lfOutPrecision=OUT_DEFAULT_PRECIS;
structFont1.lfClipPrecision=CLIP_DEFAULT_PRECIS;
structFont1.lfQuality=DEFAULT_QUALITY;
structFont1.lfPitchAndFamily=DEFAULT_PITCH | FF_ROMAN;
strcpy(structFont1.lfFaceName,"Courier");

m_Font = new CFont;
m_Font->CreateFontIndirect(&structFont1);
m_pRichEdit1->SetFont(m_Font);

//Vérification...
pFont_test= m_pRichEdit1->GetFont();
sprintf(sdum,"pFont_test:%i\n",pFont_test);
AfxMessageBox(sdum); //ERROR
pFont_Test=NULL pourquoi?????????
//pFont_test->GetLogFont(&structFont2);
//sprintf(sdum,"Charset:%i\n",structFont2.lfCharSet);
//AfxMessageBox(sdum);

Si qqn a une idée... merci

Jean-Claude

5 réponses

Avatar
Jean-Claude
prblm de mise en page...//ERROR pFont_Test=NULL pourquoi?????????

"Jean-Claude" a écrit dans le message de
news:
Bonjour...MFC, 2000
j'essaye désespérément de changer le charset de mon CRichEdit. Je fais:

LOGFONT structFont1;

structFont1.lfHeight=m_nHeight-2;
structFont1.lfWidth=m_nWidth;
structFont1.lfEscapement=0;
structFont1.lfOrientation=0;
structFont1.lfWeight=m_nWeight;
structFont1.lfItalic=m_bItalic;
structFont1.lfUnderline=m_bUnderline;
structFont1.lfStrikeOut=m_bStrikeOut;
structFont1.lfCharSet=RUSSIAN_CHARSET;
structFont1.lfOutPrecision=OUT_DEFAULT_PRECIS;
structFont1.lfClipPrecision=CLIP_DEFAULT_PRECIS;
structFont1.lfQualityÞFAULT_QUALITY;
structFont1.lfPitchAndFamilyÞFAULT_PITCH | FF_ROMAN;
strcpy(structFont1.lfFaceName,"Courier");

m_Font = new CFont;
m_Font->CreateFontIndirect(&structFont1);
m_pRichEdit1->SetFont(m_Font);

//Vérification...
pFont_test= m_pRichEdit1->GetFont();
sprintf(sdum,"pFont_test:%in",pFont_test);
AfxMessageBox(sdum); //ERROR


pFont_Test=NULL pourquoi?????????
//pFont_test->GetLogFont(&structFont2);
//sprintf(sdum,"Charset:%in",structFont2.lfCharSet);
//AfxMessageBox(sdum);

Si qqn a une idée... merci

Jean-Claude




Avatar
Yalbrieux
Bonjour,

Le CreateFontIndirect est fait pour créer une fonte à partir d'une autre
déjà existante.
Vous ne devez pas l'utiliser pour créer une nouvelle fonte.
Utilisez CreateFont.
Cordialement
Yves
Avatar
Jean-Claude
alors je fais:

void CMyDlg::setStyleCdwk()
{
m_Font = new CFont;
m_Font ->CreateFont(40,0,0,0,700,TRUE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH,"Times New Roman");

m_pRichEdit1->SetFont(m_Font);
pfonte_test = m_pRichEdit1->GetFont();
}

Malheureusement, ce GetFont() me retourne toujours 0... ???

alors que

void CMyDlg::setStyleCdwk()
{
m_Font = new CFont;
m_Font ->CreateFont(40,0,0,0,700,TRUE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH,"Times New Roman");

SetFont(m_Font);
pfonte_test = GetFont();
}

me retourne un CFont* non NULL ça doit être un prblm spécifique à mon
composant CRichEdit?
Avatar
Christian ASTOR
Jean-Claude wrote:

GetFont() me retourne NULL



MSDN =>
"
WM_GETFONT The EM_GETCHARFORMAT message is used instead.
"
Avatar
Jean-Claude
Grand merci!
"Christian ASTOR" a écrit dans le message de
news:42a16040$0$301$
Jean-Claude wrote:

> GetFont() me retourne NULL

MSDN =>
"
WM_GETFONT The EM_GETCHARFORMAT message is used instead.
"