GDI+ and double buffering
Hi everyone! I've just started using GDI+, and I've got a program which updates the graphics whenever a timer ticks. It works fine, but it flickers annoyingly. I managed to use double buffering to solve this with GDI, but I don't know how to do this in GDI+.
Here's the structure of my program:
Any help with getting rid of the flicker would be nice :) I appreciate it!
void update (HDC 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));
graphics.DrawLine(&black, 0, 530, GetSystemMetrics(SM_CXSCREEN), 530);
graphics.DrawLine(&black, orangex+170, 530, orangex+170, 450);
graphics.FillEllipse(&red, x, y, 50, 50);
graphics.FillEllipse(&blue, bluex, bluey, 10, 150);
graphics.FillEllipse(&orange, orangex, orangey, 150, 10);
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
//calculate new coordinates for the GDI objects.
InvalidateRect(hwnd, NULL, TRUE);
hdc = BeginPaint(hwnd, &ps);