Okay, I'll look into creating a nice Class before my code gets really hectic.
Also, I've tried altering my code so that instead of constantly creating and destroying HDCs, BITMAPS, etc. for every repaint they last the entire life cycle of my program and are initialized early, but my program is eating up the CPU like 96% now. If I acquire a device context at the birth of my program (i.e. init() function) and do not release it until the end of my program (i.e. freeResources()) is this what is causing my app. to run at 96% CPU?
Also, I had hoped SetDimensionsEx() would resize the bitmap buffer later, but there turns out to be no function capable of this.
My altered code from my previous code posted earlier:
HBRUSH backgroundBrush; // Brush used for painting the background.
// Repaint the window with the background brush defined above.
FillRect(hdcBuffer, &rect, backgroundBrush);
deck.redrawAll(hdcBuffer, rect); // Redraws all relevant cards to the screen.
// Copy back buffer into screen device context for display.
BitBlt(screenHDC, 0, 0, rect.right, rect.bottom, hdcBuffer, 0, 0, SRCCOPY);
bool initialize(HWND windowHandle)
screenHDC = GetDC(windowHandle);
hdcBuffer = CreateCompatibleDC(screenHDC);
// Forced to define a large size 1280x1024 because impossible to resize bmpBuffer later.
bmpBuffer = CreateCompatibleBitmap(screenHDC, 1280, 1024);
backgroundBrush = CreateSolidBrush(RGB(0,155,0));
void freeResources(HWND windowHandle)
DeleteDC(hdcBuffer); // Free resources.
DeleteObject(bmpBuffer); // Free resources.
// Delete brush created earlier.