var C: TCanvas; b: TBitmap; H: HDC; R: TRect; hand: THandle;
p: TPoint;
J: TJpegImage;
m, n: INTEGER;
name: array[0..255] of char;
begin
B := TBitmap.Create;
C := TCanvas.Create;
GetCurSorPos(P); //取得鼠標所在區域坐標
Hand := WindowFromPoint(P); //取得坐標所在窗體句柄
FillChar(name, SizeOf(name), #0); //
GetWindowText(Hand, name, 255); // 取得窗口標題
if name = '' then CopyMemory(@name, PCHAR(inttostr(hand)), Length(inttostr(hand)) + 1); //用句柄
if hand = 0 then exit;
H := GetWindowDC(Hand); //獲取整個窗口(包括邊框、滾動條、標題欄、菜單等)的設備場景 返回值 Long
try
GetWindowRect(hand, R); //取得句柄對應窗體的矩形區域
B.Width := R.Right - R.Left;
B.Height := R.Bottom - R.Top;
C.Handle := H; //將描述表賦給畫布的句柄,此時畫布就代表整個屏幕了
B.Canvas.CopyRect(Rect(0, 0, B.Width, B.Height), C, Rect(0, 0, B.Width, B.Height));
//Image1.Picture.Bitmap.Assign(B);
finally
C.Free;
B.Free;
ReleaseDC(Hand, H); //釋放設備上下文環境
end;
end;
以前寫的壹個類似軟件 ,應該和妳的問題相符,妳可以參考壹下。