抓 圖 實(shí) 際 上 是 位 圖 的 復(fù) 制 , Windows在 復(fù) 制 位 圖 時(shí) 是 不 會(huì) 受 鼠 標(biāo)
光 標(biāo) 的 影 響 的 。 可 以 先 抓 圖 , 然 后 在 使 用 DrawIcon將 鼠 標(biāo) 光 標(biāo) 畫 上 去 。
procedure TForm1.FormClick(Sender: TObject);
var
winHWND, hCur: integer;
winDC: integer;
rect: TRect;
pt: TPoint;
fBitmap: TBitmap;
begin
hCur := GetCursor(); // 取得光標(biāo)句柄
GetCursorPos(pt); // 取得光標(biāo)位置
winHWND := GetDesktopWindow();
winDC := GetDC(winHWND);
GetWindowRect(winHWND, rect);
fBitmap := TBitmap.create;
try
fBitmap.width := rect.right - rect.left;
fBitmap.height := rect.bottom - rect.top;
BitBlt(fBitmap.canvas.handle, 0, 0, fBitmap.width, fBitmap.height, winDC, 0, 0, SRCCOPY);
DrawIcon(fBitmap.canvas.handle, pt.x, pt.y, hCur); // 畫光標(biāo)
ReleaseDC(winHWND, winDC);
Image1.Picture.Bitmap.Assign(fBitmap);
finally
fBitmap.Free;
end;
end;
光 標(biāo) 的 影 響 的 。 可 以 先 抓 圖 , 然 后 在 使 用 DrawIcon將 鼠 標(biāo) 光 標(biāo) 畫 上 去 。
procedure TForm1.FormClick(Sender: TObject);
var
winHWND, hCur: integer;
winDC: integer;
rect: TRect;
pt: TPoint;
fBitmap: TBitmap;
begin
hCur := GetCursor(); // 取得光標(biāo)句柄
GetCursorPos(pt); // 取得光標(biāo)位置
winHWND := GetDesktopWindow();
winDC := GetDC(winHWND);
GetWindowRect(winHWND, rect);
fBitmap := TBitmap.create;
try
fBitmap.width := rect.right - rect.left;
fBitmap.height := rect.bottom - rect.top;
BitBlt(fBitmap.canvas.handle, 0, 0, fBitmap.width, fBitmap.height, winDC, 0, 0, SRCCOPY);
DrawIcon(fBitmap.canvas.handle, pt.x, pt.y, hCur); // 畫光標(biāo)
ReleaseDC(winHWND, winDC);
Image1.Picture.Bitmap.Assign(fBitmap);
finally
fBitmap.Free;
end;
end;