well, the thing is, i'm such a n00b, i didn't really understand what you meant with any of that syntax at first, but running through a simple tutorial showed me how to handle messages and stuff (something i really wasn't accustomed to).
i got all of that to work; i got my one pixel to pop up, now i'm going one step further. I'm trying to tie it into a loop, as to make more than one pixel. here's my code so far from my main window:
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
{
HDC hDC=GetDC(hwnd);
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
SetPixel(hDC, 100, 100, (COLORREF) 0xffffffff);
EndPaint(hwnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
I'm guessing that i'd need to throw a for statement in there somewhere, but i don't really know where. i tried a few experiments, but nothing happened. i either got an error, or no pixels at all. suggestions?
i think i'll need to make a loop somewhere else, generating the coordinate values, then feed them via messages to there. I'm probably wrong though. can you help?
EDIT:
I did manage to get it to work, putting the loop before the beginpaint statement, and ending it after the endpaint statement, this code gave me a straight line on my form:
Code:
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
{
HDC hDC=GetDC(hwnd);
PAINTSTRUCT ps;
for (int n = 30; n < 60; n++) {
BeginPaint(hwnd, &ps);
SetPixel(hDC, n, 100, (COLORREF) 0xffffffff);
EndPaint(hwnd, &ps);
}
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
is this the best way to do it?