このコードは、カーソルの周りに最大100x100のボックスでウィンドウにペイントされた画像をキャプチャしようとしています。BitBltはここのどちらの場所でも0を返していません。問題は、ウィンドウの背景からグローバルに宣言されたHDCであるメタに画像をコピーしようとしているBitBltの最初の関数呼び出しにあると確信しています。 。HDCを完全にメモリ内に作成するだけでなく、空白のビットマップを作成してロードし、それに関連付けられたハンドルに新しい画像をキャプチャしようとしましたが、消しゴムのように機能して白いボックスを描画するだけでした。カーソルの動きに合わせて。関連するコードを以下に示します。mouseRectとclientRectは、それぞれカーソルとクライアントの長方形の周りのボックスに関連するグローバル変数です。どんな助けでもありがたいです、ありがとう!
case WM_CREATE:
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
GetClientRect(hWnd, &clientRect);
hdc = GetDC(hWnd);
meta = CreateCompatibleDC(hdc);
return 0;
case WM_MOUSEMOVE:
x = LOWORD(lParam);
y = HIWORD(lParam);
hdc = GetDC(hWnd);
BitBlt(hdc, mouseRect.left, mouseRect.top, mouseRect.right-mouseRect.left, mouseRect.bottom-mouseRect.top, meta, 0, 0, SRCCOPY);
ReleaseDC(hWnd, meta);
meta = CreateCompatibleDC(hdc);
if(y<50)
mouseRect.top = 0;
else
mouseRect.top = y-50;
if(x<50)
mouseRect.left = 0;
else
mouseRect.left = x-50;
if(clientRect.right-x<50)
mouseRect.right = clientRect.right;
else
mouseRect.right = x+50;
if(clientRect.bottom-y<50)
mouseRect.bottom = clientRect.bottom;
else
mouseRect.bottom = y+50;
BitBlt(meta, 0, 0, mouseRect.right-mouseRect.left, mouseRect.bottom-mouseRect.top, hdc, mouseRect.left, mouseRect.top, SRCCOPY);
ReleaseDC(hWnd, hdc);
return 0;