WIn API Basic Paint program
- by Tom Burman
Just trying to learn a bit of Win API. Im trying to make a basic drawing app, a bit like MS Paint.
For the time being im 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.
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;
}
}
Thanks for any help!