Why BitBlt does not copy the correct part

When I try to use the code below to copy the application icon to the upper left corner of the client area, I used the following code:

case WM_PAINT:
    hdcClient = BeginPaint (hwnd, &ps) ;
    hdcWindow = GetWindowDC (hwnd) ;

    cxSource = GetSystemMetrics (SM_CXSIZEFRAME) + GetSystemMetrics (SM_CXSIZE) ;
    cySource = GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION) ;

    BitBlt (hdcClient, 0, 0, cxSource, cySource, hdcWindow, 0, 0, SRCCOPY) ;

    ReleaseDC (hwnd, hdcWindow) ;
    EndPaint (hwnd, &ps) ;
    return 0 ;
    ......

However, what I always get is:

enter image description here

It seems that hdcWindow get is the hdc window below it. I cannot understand what is wrong with my call to BitBlt ().

  • I did this in a windows 7 window.
+3
source share
1 answer
hdcClient = BeginPaint (hwnd, &ps) ;
hdcWindow = GetWindowDC (hwnd) ;

cxSource = GetSystemMetrics (SM_CXSIZEFRAME) + GetSystemMetrics (SM_CXSIZE) ;
cySource = GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION) ;

BitBlt (hdcClient, 0, 0, cxSource, cySource, hdcWindow, 0, 0, SRCCOPY) ;

destination - hdcClient, , BeginPaint. BeginPaint , , . ( / ..), , , , hdcWindow.

0

All Articles