Các ví dụ về hình
1. Vẽ điểm đường, văn bảnCPaintDC dc(this); // device context for paintinghPen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 255)); dc.SelectObject(hPen); dc.MoveTo(10,10);dc.LineTo(100,100);dc.SetPixel(50,50,RGB(255,0,0));dc.SetTextAlign(TA_CENTER);long n=1234; char st[4]; ultoa(n, st, 10);dc.TextOut(50,50,st);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;// Draw the icondc.DrawIcon(x, y, m_hIcon);2. Vẽ đa giácCPaintDC dc(this); // device context for paintingPOINT PointArr[3]; HPEN hPen; PointArr[0].x = 50; PointArr[0].y = 10; PointArr[1].x = 250; PointArr[1].y = 50; PointArr[2].x = 125; PointArr[2].y = 130; hPen = (HPEN)CreatePen(PS_SOLID, 2, RGB(0, 0, 255)); dc.SelectObject(hPen); dc.Polyline(PointArr, 3); 3. Tô màuCPaintDC dc(this); // device context for paintingHPEN hPen; HBRUSH hBrush, hOldBrush; //V? hai hình ch? nh?t v?i bút v? Black hPen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0, 255)); dc.SelectObject(hPen); dc.Rectangle(10, 10, 50, 50); dc.Rectangle(100, 100, 200, 200); // Dùng m?t trong các m?u tô có s?n ?? tô hình hBrush = (HBRUSH)GetStockObject(GRAY_BRUSH); dc.SelectObject(hBrush); dc.FloodFill(30, 30, RGB(0, 0, 255)); // T?o m?u tô m?i ?? tô hình th? hai hBrush = (HBRUSH)CreateHatchBrush(HS_DIAGCROSS, RGB(0, 255, 255)); hOldBrush = (HBRUSH)dc.SelectObject(hBrush); dc.FloodFill(150, 150, RGB(0, 0, 255)); dc.SelectObject(hOldBrush); . 10, 50, 50); dc.Rectangle(100, 100, 200, 200); // Dùng m?t trong các m?u tô có s?n ?? tô hình hBrush = (HBRUSH)GetStockObject(GRAY_BRUSH); dc.SelectObject(hBrush);. // device context for paintingHPEN hPen; HBRUSH hBrush, hOldBrush; //V? hai hình ch? nh?t v?i bút v? Black hPen = (HPEN)CreatePen(PS_SOLID, 1, RGB(0, 0,