Code:
void update (HWND hwnd, HDC hdc)
{
RECT rc;
GetClientRect(hwnd, &rc);
Bitmap buffer(rc.right, rc.bottom);
Graphics graphicsbuf(&buffer);
Graphics graphics(hdc);
Pen black(Color(255, 0, 0, 0), 4);
SolidBrush red(Color(255, 255, 0, 0));
SolidBrush blue(Color(255, 0, 0, 255));
SolidBrush orange(Color(255, 200, 200, 0));
graphicsbuf.DrawLine(&black, 0, 530, GetSystemMetrics(SM_CXSCREEN), 530);
graphicsbuf.DrawLine(&black, orangex+170, 530, orangex+170, 450);
graphicsbuf.FillEllipse(&red, x, y, 50, 50);
graphicsbuf.FillEllipse(&blue, bluex, bluey, 10, 150);
graphicsbuf.FillEllipse(&orange, orangex, orangey, 150, 10);
graphics.DrawImage(&buffer, 0, 0);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
//buttons which change some of the coordinates, drawn using CreateWindowEx with hwnd.
case IDC_RIGHT:
orangex = orangex + 20;
break;
case IDC_LEFT:
orangex = orangex - 20;
break;
}
break;
case WM_TIMER:
//Update coordinates here
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
update(hwnd, hdc);
EndPaint(hwnd, &ps);
break;
... but now, the flickering is even worse and it runs slower too - have I got it right (I'm guessing not!!). Thanks for your help yet again.