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:
- The line starts drawing straight away rather then waiting for the left click
- 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;
}