CodePudding user response:
Void CSDI3View: : ontouch * pDC (CDC)
{
CSDI3Doc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
//TODO: add the draw code for native data here
//save DC
Int nSaveDC=pDC - & gt; SaveDC ();
//the client area coordinates range
CRect rcClient;
GetClientRect (& amp; RcClient);
//fill background
PDC - & gt; FillSolidRect (rcClient, RGB (250, 250, 250));
Draw a line//
{
//create the brush
CPen linePen (PS_SOLID, 2, RGB (255, 0, 0));
//candidate brush
CPen * pOldPen=pDC - & gt; SelectObject (& amp; LinePen);
//move to the starting point for
PDC - & gt; MoveTo (rcClient TopLeft ());
Draw a line//
PDC - & gt; LineTo (rcClient BottomRight ());
//restore brush
PDC - & gt; SelectObject (pOldPen);
}
//write
{
//create a font
CFont mFont;
MFont. CreatePointFont (240, _T (" Arial "));
//candidate font
CFont * pOldFont=pDC - & gt; SelectObject (& amp; MFont);
//set the font color
Int txColor=pDC - & gt; SetTextColor (RGB (0, 0, 255));
//set the background transparent
Int bkMode=pDC - & gt; SetBkMode (TRANSPARENT);
//output font
PDC - & gt; TextOut (10, 10, _T (" font "));
//recovery background model
PDC - & gt; SetBkMode (bkMode);
//resume font color
PDC - & gt; SetTextColor (txColor);
//resume font
PDC - & gt; SelectObject (pOldFont);
}
//restore DC
PDC - & gt; RestoreDC (nSaveDC);
}
CodePudding user response:
Finished drawing up refreshedCodePudding user response:
RestoreDC is restored, removedCodePudding user response: