CDC* PASCAL CDC::FromHandle(HDC hDC) { CHandleMap* pMap = afxMapHDC(TRUE); //create map if not exist ASSERT(pMap != NULL); CDC* pDC = (CDC*)pMap->FromHandle(hDC); ASSERT(pDC == NULL || pDC->m_hDC == hDC); return pDC; }
void CDC::ReleaseOutputDC() // Release the Output DC { #ifdef _DEBUG CHandleMap* pMap = afxMapHDC(); if (pMap != NULL && pMap->LookupPermanent(m_hDC) == this) { TRACE(traceAppMsg, 0, "Cannot Release Output hDC on Attached CDC.\n"); ASSERT(FALSE); } #endif m_hDC = NULL; }
void CDC::SetOutputDC(HDC hDC) // Set the Output DC { #ifdef _DEBUG CHandleMap* pMap = afxMapHDC(); if (pMap != NULL && pMap->LookupPermanent(m_hDC) == this) { TRACE0("Cannot Set Output hDC on Attached CDC.\n"); ASSERT(FALSE); } #endif m_hDC = hDC; }
HDC CDC::Detach() { HDC hDC = m_hDC; if (hDC != NULL) { CHandleMap* pMap = afxMapHDC(); // don't create if not exist if (pMap != NULL) pMap->RemoveHandle(m_hDC); } ReleaseAttribDC(); m_hDC = NULL; return hDC; }
BOOL CDC::Attach(HDC hDC) { ASSERT(m_hDC == NULL); // only attach once, detach on destroy ASSERT(m_hAttribDC == NULL); // only attach to an empty DC if (hDC == NULL) return FALSE; CHandleMap* pMap = afxMapHDC(TRUE); // create map if not exist ASSERT(pMap != NULL); pMap->SetPermanent(m_hDC = hDC, this); SetAttribDC(m_hDC); // Default to same as output return TRUE; }
void PASCAL CDC::DeleteTempMap() { CHandleMap* pMap = afxMapHDC(); if (pMap != NULL) pMap->DeleteTemp(); }