Graphics Help

Brandon
2014-02-16
2014-02-16
  • Brandon
    Brandon
    2014-02-16

    I'm not sure how to get the code I'm using to work. I need to add two separate rectangles to the
    code already prepared, but it won't compile. The relevant code follows, so please help!

    case WM_PAINT:
    hdc = BeginPaint(hwnd,&ps);
    // obtain a yellow pen for drawing walls of container in yellow
    pen = CreatePen(PS_SOLID,4, RGB(255,255,0));
    SelectObject(hdc,pen);
    // obtain a black bruch to draw 'background' of container in black
    blackBrush = CreateSolidBrush(RGB(0,0,0));
    SelectObject(hdc,blackBrush);
    // draw container and its walls
    Rectangle(hdc,XL-10,YT-10,XR+10,YB+10);
    DeleteObject(pen);
    DeleteObject(blackBrush);
    //draw the orifices (most relevant)
    pen2 = CreatePen(PS_SOLID, 4, RGB(255, 255, 0));
    SelectObject(hdc,pen2);
    brush = CreateSolidBrush(RGB(255,255,0));
    Rectangle(hdc, Mid - 1, 0, Mid, 380);
    DeleteObject(pen2);

              pen3 = CreatePen(PS_SOLID, 4, RGB(255,255, 0));
              SelectObject(hdc, pen3);
              brush2 = CreateSolidBrush(RGB(255,255,0));
              Rectangle(hdc, 200.200.200.200);
              DeleteObject(pen3);
    
             // draw ball objects at their initial locations in yellow
           for(j = 0; j <= 19; j++)
               drawBall(hdc,ballAry[j],255);
               ReleaseDC(hwnd,hdc);
               EndPaint(hwnd,&ps);
            break;
    
     
  • Merak
    Merak
    2014-02-16

    From MSDN:
    SetDCPenColor(hdc, RGB(0,0,255));
    // Drawing a rectangle with the current Device Context
    Rectangle(hdc,100,300,200,400);

       //    Changing the color of the brush to Green
            SetDCBrushColor(hdc, RGB(0,255,0));