Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Just trying to learn a bit of Win API. I'm trying to make a basic drawing app, a bit like MS Paint.

For the time being I'm trying to get one function to work which is, when you left click and drag the mouse around the screen a line is drawn behind the mouse. Heres what I have so far, but for some reason:

  1. The line starts drawing straight away rather then waiting for the left click
  2. The line isn't solid its very dotty

The code:

case WM_MOUSEMOVE:
{
    if(MK_LBUTTON){
        hdc = GetDC(hwnd);
        hPen = CreatePen(PS_SOLID,5,RGB(0, 0, 255));
        SelectObject(hdc, hPen);

        int x = LOWORD(lParam);
        int y = HIWORD(lParam);

        MoveToEx(hdc,x,y,NULL);
        LineTo(hdc, LOWORD(lParam), HIWORD(lParam));
        ReleaseDC(hwnd,hdc);
    }
    else
        break;
}
share|improve this question
I don't think this belongs to GameDev, SO would be a better choice – Jaakko Lipsanen Dec 2 '12 at 11:46

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.