#define F #ifdef A pDC->TextOut(10, 10, "Hello World"); CString mbuf; int x = 10; mbuf.Format( "X = %d, in hex X = 0x%x", x, x ); pDC->TextOut( 50, 50, mbuf ); #endif #ifdef B CRect rect; GetClientRect( &rect ); int x1 = rect.TopLeft().x; int y1 = rect.TopLeft().y; int x2 = rect.BottomRight().x; int y2 = rect.BottomRight().y; pDC->MoveTo( x1, y1 ); pDC->LineTo( x2, y2 ); pDC->MoveTo( x1, y2 ); pDC->LineTo( x2, y1 ); #endif #ifdef C CRect rect; GetClientRect( &rect ); CPoint p1 = rect.TopLeft(); CPoint p2 = rect.BottomRight(); CPoint p3; p3.x = p1.x; p3.y = p2.y; CPoint p4; p4.x = p2.x; p4.y = p1.y; pDC->MoveTo( p1 ); pDC->LineTo( p2 ); pDC->MoveTo( p3); pDC->LineTo( p4 ); #endif #ifdef D CPen aPenR; aPenR.CreatePen( PS_SOLID, 2, RGB(255,0,0) ); CPen* pOldPen = pDC->SelectObject( &aPenR ); CRect rect; GetClientRect( &rect ); int x1 = rect.TopLeft().x; int y1 = rect.TopLeft().y; int x2 = rect.BottomRight().x; int y2 = rect.BottomRight().y; pDC->MoveTo( x1, y1 ); pDC->LineTo( x2, y2 ); CPen aPenB; aPenB.CreatePen( PS_SOLID, 10, RGB(0, 0, 255) ); pDC->SelectObject( &aPenB ); pDC->MoveTo( x1, y2 ); pDC->LineTo( x2, y1 ); pDC->SelectObject( pOldPen ); #endif #ifdef E CBrush aBrush0(RGB(255,0,0)); CBrush* pOldBrush = pDC->SelectObject(&aBrush0); pDC->Rectangle(10, 10, 100, 100 ); CBrush aBrush1(HS_DIAGCROSS, RGB(255,0,0)); pDC->SelectObject(&aBrush1); pDC->Rectangle(100, 100, 200, 200 ); CBrush aBrush2; aBrush2.CreateHatchBrush(HS_CROSS, RGB(0,255,0) ); pDC->SelectObject(&aBrush2); pDC->Rectangle(300, 100, 400, 200 ); pDC->SelectObject(pOldBrush); #endif #ifdef F int y = 50; int x = 10; pDC->MoveTo( x, y ); for( ; x<400; x++) { y = rand() % 100 + 50; pDC->LineTo( x,y); } #endif #ifdef G /* MM_HIENGLISH: Each logical unit is converted to 0.001 inch. Positive x is to the right; positive y is up. MM_HIMETRIC: Each logical unit is converted to 0.01 millimeter. Positive x is to the right; positive y is up. MM_ISOTROPIC: Logical units are converted to arbitrary units with equally scaled axes; that is, 1 unit along the x-axis is equal to 1 unit along the y-axis. Use the SetWindowExt and SetViewportExt member functions to specify the desired units and the orientation of the axes. GDI makes adjustments as necessary to ensure that the x and y units remain the same size. MM_LOENGLISH: Each logical unit is converted to 0.01 inch. Positive x is to the right; positive y is up. MM_LOMETRIC: Each logical unit is converted to 0.1 millimeter. Positive x is to the right; positive y is up. MM_TEXT: Each logical unit is converted to 1 device pixel. Positive x is to the right; positive y is down. MM_TWIPS: Each logical unit is converted to 1/20 of a point. (Because a point is 1/72 inch, a twip is 1/1440 inch.) Positive x is to the right; positive y is up. */ pDC->SetMapMode( MM_TEXT ); pDC->MoveTo( 10, 100 ); pDC->LineTo( 100, 100 ); Sleep( 500 ); pDC->SetMapMode( MM_LOENGLISH ); pDC->MoveTo( 10, -100 ); pDC->LineTo( 100, -100 ); Sleep( 500 ); pDC->SetMapMode( MM_HIENGLISH ); pDC->MoveTo( 10, -100 ); pDC->LineTo( 100, -100 ); #endif #ifdef H CPen *lineTypes[5]; UINT PenStyle[] = { PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT }; for(int i=0; i<5; i++) { lineTypes[i] = new CPen( PenStyle[i], 1, RGB(255,0,0) ); } CPen* pOldPen = pDC->SelectObject( lineTypes[0] ); for( i=0; i<5; i++) { pDC->SelectObject( lineTypes[i] ); pDC->MoveTo( 10, i*20 + 10); pDC->LineTo(100, i*20 + 10); } pDC->SelectObject( pOldPen ); #endif #ifdef Z // See CTipView::OnDraw() for TIP! #endif