Creating screenshots using BitBlt () has not become easier since the addition of DWM (Desktop Window Manager, aka Aero). Petzold's sample code suffers from a subtle time problem; it takes a screenshot too soon. He does this while Aero is still busy animating the frame, fading into view. So, you see what is outside the window, it may already have partially disappeared depending on how quickly the first WM_PAINT message is generated.
You can easily fix this by disabling the effect:
#include <windows.h>
#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")
CreateWindow():
BOOL disabled = TRUE;
DwmSetWindowAttribute(hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &disabled, sizeof(disabled));
, Blt , DWM , .
, , . Aero, , , . , , , BitBlt(), , . SO, .