I'm currently getting back to some Windows Programming using Petzold's book (5th edition). I compiled the following example using BitBlt and it doesn't work as it is supposed to.
It should copy the Window's icon of (CxSource, CySource) size and replicate it on the whole window's surface. What happens, in reality, using Windows 7 is that the bitmap below the window gets sourced and copied into the drawing surface i.e. hdcClient.
I don't understand why it behaves like this knowing that it's clear the DC passed to BitBlt is hdcWindow, which refers to a device context obtained via a GetWindowDC(hwnd) of the current application.
I first thought it was due to the fact the transparency mode is enabled by default, but deactivating it doesn't change anything. BitBlt seems to always take the surface below the application Window! I don't get it! :) Anyone knows why it works that way and how to fix it?
cxSource
andcySource
point to the wrong part of the window. It still is possible that "frame thickness + default size" is no longer a reliable way to grab the window icon, but that, or an alternative, seems not mentioned on MSDN. – Jongware