What part of your code doesn't work? Do you have a resource leak? Rectangle drawn too small? Nothing drawn at all? Program exits with an unhandled exception? Have you checked all return values? What did they give? Called GetLastError() on failure? ...
Your calculations are off (bmWidth * bmWidthBytes) should be (bmHeight * bmWidthBytes) Doesn't matter when they have the same value, but still.
Why not use
CreateCompatibleBitmap[
^] instead?
From MSDN "
An application must not delete a DC whose handle was obtained by calling the GetDC function. Instead, it must call the ReleaseDC function to free the DC."