WIn API Basic Paint program
Posted
by
Tom Burman
on Game Development
See other posts from Game Development
or by Tom Burman
Published on 2012-12-02T11:44:45Z
Indexed on
2012/12/02
17:22 UTC
Read the original article
Hit count: 320
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!
© Game Development or respective owner