problem code:
pMetaFileDC->SelectObject(newPen);
when debug, it causes an assertion. the source is:
{ ASSERT(m_hDC == m_hAttribDC); // ASSERT a simple CDC object
return (hObject != NULL) ::SelectObject(m_hDC, hObject) : NULL; }
ok, then i write this:
pDoc->pMetaFileDC->SetAttribDC(pDoc->pMetaFileDC->GetSafeHdc());
but this fuciton do not work as supposed. and the assertion remains.
look into the source code:
void CMetaFileDC::SetAttribDC(HDC hDC) // Set the Attribute DC
{
if (hDC != m_hDC)
CDC::SetAttribDC(hDC);
if (m_hDC == m_hAttribDC) // if we somehow got to this, correct it
ReleaseAttribDC();
}
i am really confused! what am i supposed to do
in addition, if i do nothing but use the release vision, i find it works quite well without any problem.

a paradox in mfc head file?
Tazwng
Did you call CMetaFileDC::Create
Ed Hintz
Russell177576
Hi,
This is a bug in your code.
pMetaFileDC->SelectObject(newPen);
should be
pMetaFileDC->SelectObject(&newPen);
then you will call into
_AFXWIN_INLINE CGdiObject* CDC::SelectObject(CGdiObject* pObject)
not into
_AFXWIN_INLINE HGDIOBJ CDC::SelectObject(HGDIOBJ hObject)
Thanks,Nikola
VC++