When copying DIB data into clipboard,
you must pay attention to the allocation and deallocation of the data handle, hDIB.
The data handle hDIB must be allocated using GlobalAlloc with GMEM_MOVEABLE flag, not with GMEM_FIXED.
And you must NOT free the data handle even after your application calls ::CloseClipboard(),
although the MSDN says we can do.
Instead of freeing the data handle right after calling ::CloseClipboard(),
you can GlobalFree hDIB in WM_DESTROYCLIPBOARD message handler of the clipboard owner.
Otherwise, the other application may refer to invalid data handle or your application may fail in every second clipboard-copy procedure.
Function 3 (CopyWndToClipboard()) will only work correctly when the whole window is inside the desktop rectangle. If you move the window e.g. halfway out of the visible screen, the copied image will be corrupted.
To prevent this, you'd have to add some checks and deflate the copy rect according to the screen rect.