Please observe the following code; it can give you your next ideas :) :
class CDrawTransformer
{
CDC* m_pDC;
int m_iOriginalDC;
int m_iOriginalMode;
XFORM m_xOriginalForm;
XFORM m_xWorkingForm;
public:
CDrawTransformer(CDC* pDC, const CRect& crViewCell, int iZoomPercent);
~CDrawTransformer();
void Release();
};
CDrawTransformer::CDrawTransformer(CDC* pDC,
const CRect& crViewCell,
int iZoomPercent)
: m_pDC(pDC)
{
ASSERT(m_pDC->GetSafeHdc());
m_iOriginalDC = SaveDC(m_pDC->m_hDC);
m_iOriginalMode = SetGraphicsMode(m_pDC->m_hDC, GM_ADVANCED);
GetWorldTransform(m_pDC->m_hDC, &m_xOriginalForm);
float fZoomFactor = (float) iZoomPercent / 100.0f;
m_xWorkingForm.eM11 = fZoomFactor;
m_xWorkingForm.eM12 = 0.0f;
m_xWorkingForm.eM21 = 0.0f;
m_xWorkingForm.eM22 = fZoomFactor;
m_xWorkingForm.eDx = (float) crViewCell.left;
m_xWorkingForm.eDy = (float) crViewCell.top;
SetWorldTransform(m_pDC->m_hDC, &m_xWorkingForm);
}
CDrawTransformer::~CDrawTransformer()
{
Release();
}
void CDrawTransformer::Release()
{
if (m_pDC->GetSafeHdc()) {
SetWorldTransform(m_pDC->m_hDC, &m_xOriginalForm);
SetGraphicsMode(m_pDC->m_hDC, m_iOriginalMode);
RestoreDC(m_pDC->m_hDC, m_iOriginalDC);
m_pDC = NULL;
}
}
void CYourWnd::SomeDrawing(CDC* pDC,
const CRect& crViewCell,
int iZoomPercent)
{
CDrawTransformer cTransformer(pDC, crViewCell, iZoomPercent);
graphics g(pDC, ...);
GdiPlusDraw(g, crViewCell.Size());
}
void CYourWnd::GdiPlusDraw(graphics& g, const CSize& sizeCell)
{
}