SelectObject( pFont ) returns NULL

I have defined a CFont* member in my CFormView class. The font is created as follows:
<snip>
LOGFONT lf;

lf.lfHeight = -100;
lf.lfWidth = 0;
lf.lfEscapement = 0;
lf.lfOrientation = 0;
lf.lfWeight = FW_NORMAL;
lf.lfItalic = (BYTE) 0;
lf.lfUnderline = (BYTE) 0;
lf.lfStrikeOut = (BYTE) 0;
lf.lfCharSet = (BYTE) ANSI_CHARSET;
lf.lfOutPrecision = (BYTE)OUT_DEFAULT_PRECIS;
lf.lfClipPrecision = (BYTE) CLIP_DEFAULT_PRECIS;
lf.lfQuality = (BYTE) DEFAULT_QUALITY;

lf.lfPitchAndFamily = (BYTE) DEFAULT_PITCH|FF_DONTCARE;
strcpy( lf.lfFaceName, _T("Arial") );

m_pTextFont = new CFont;
ASSERT( m_pTextFont );

if( ! m_pTextFont->CreateFontIndirect( &lf ) )
      TRACE0("error creating Arial font\n");      

ASSERT_VALID( m_pTextFont );
</snip>

When I select the CFont* object into the device context in OnPrint(), pDC->SelectObject( m_pTextFont ) consistently returns NULL, and my font is not selected into the DC:

<snip>
if( pDC->IsPrinting() )
      pDC->SetMapMode( MM_HIENGLISH );

CFont *      pOldFont = pDC->SelectObject( m_pTextFont );
</snip>

Any ideas as to why this is happening ?
xn12z9iAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Nicolay_ChConnect With a Mentor Commented:
Try use you code without LOGFONT structure....
0
 
cdesignerCommented:
try to make "LOGFONT lf; "
a global variable

I use LOGFONT scructure always before print.
0
All Courses

From novice to tech pro — start learning today.