Beispiel #1
0
int DrawGr(HDC hdc)
{
    HPEN hPen, hOldPen;
    HBRUSH hBrush, hOldBrush;

    hPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
    hOldPen = SelectObject(hdc, hPen);
    hBrush = CreateHatchBrush(HS_CROSS, RGB(0, 255, 0));
    hOldBrush = SelectObject(hdc, hBrush);
    Rectangle(hdc, 10, 10, 200, 100);
    SelectObject(hdc, hOldPen);
    SelectObject(hdc, hOldBrush);
    DeleteObject(hPen);
    DeleteObject(hBrush);

    hPen = CreatePen(PS_DASH, 1, RGB(255, 100, 10));
    hOldPen = SelectObject(hdc, hPen);
    hBrush = CreateHatchBrush(HS_BDIAGONAL, RGB(0, 0, 255));
    hOldBrush = SelectObject(hdc, hBrush);
    Rectangle(hdc, 40, 40, 240, 140);
    SelectObject(hdc, hOldPen);
    SelectObject(hdc, hOldBrush);
    DeleteObject(hPen);
    DeleteObject(hBrush);

    hPen = CreatePen(PS_DOT, 1, RGB(100, 100, 100));
    hOldPen = SelectObject(hdc, hPen);
    SelectObject(hdc, GetStockObject(NULL_BRUSH));
    Rectangle(hdc, 70, 70, 270, 270);
    SelectObject(hdc, hOldPen);
    DeleteObject(hPen);

    DrawRect4(hdc); /* Call compiled function */
    return 0;
}
Beispiel #2
0
int DrawSysButton(HDC hdc, RECT *pRect, COLORREF clrBorder)
{
    HGDIOBJ hPen = NULL;
    HGDIOBJ hOldPen; 
    int i;
    POINT prt[3];
    
    int width = pRect->right - pRect->left;
    RECT rc[3] = {
        {pRect->left, pRect->top, pRect->left + width*0.31, pRect->bottom},
        {pRect->left + width*0.31, pRect->top, pRect->left + width*0.62, pRect->bottom},
        {pRect->left + width*0.62, pRect->top, pRect->right, pRect->bottom}
    };
    for (i = 0; i < 3; i++){
        prt[i].x = (rc[i].left + rc[i].right)/2;
        prt[i].y = (rc[i].top + rc[i].bottom)/2;
    }

    hPen = CreatePen(PS_SOLID, 2, clrBorder);
    hOldPen = SelectObject(hdc, hPen);

    DrawLine(hdc, prt[0].x - 4, prt[0].y, 
                  prt[0].x + 4, prt[0].y);

    DrawRect4(hdc, prt[1].x - 5, prt[1].y - 3, 
                   prt[1].x + 5, prt[1].y + 3);

    DrawLine(hdc, prt[2].x - 4, prt[2].y - 4, 
                  prt[2].x + 4, prt[2].y + 4);
    DrawLine(hdc, prt[2].x - 4, prt[2].y + 4,
                  prt[2].x + 4, prt[2].y - 4);

    SelectObject(hdc, hOldPen);
    DeleteObject(hPen);
    return 0;
}