Why BitBlt has different result on different place

173 Views Asked by At

I write a test sample for the BitBlt, in WinProc, the WM_PAINT does this: it will repeat draw the small block from window (0,0) to the client area.

      case WM_CREATE:{
          cxSource = GetSystemMetrics (SM_CXSIZEFRAME) + GetSystemMetrics (SM_CXSIZE) ;
          cySource = GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION) ;
          return 0 ;

      case WM_PAINT:
          hdcClient = BeginPaint (hwnd, &ps) ;
          hdcWindow = GetWindowDC (hwnd) ;
          RECT rcClient; 
          GetClientRect(hwnd, &rcClient);
          for (y = 0 ; y < rcClient.bottom ; y += cySource)
              for (x = 0 ; x < rcClient.right ; x += cxSource)
                  BitBlt (hdcClient, x, y, cxSource, cySource, hdcWindow, 0, 0, SRCCOPY) ;

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

But if I write a function do the same thing and mark the above code, the result is one big picture, can anybody tell me why?

This sample is from programming windows CH14 BitBlt project and I modify some. The project target is to use the small pattern from window(0,0,cxSource, cySource) to fill the client area, but if I write this in another function, the result is, only one big picture. Thanks in advance.

0

There are 0 best solutions below