如何抓屏时把鼠标也抓上?? (50分)

  • 主题发起人 主题发起人 snappy
  • 开始时间 开始时间
你是想抓图还是想编程实现?

如果只是抓图,很多抓图软件都有这个功能。

如果要编程实现,小弟我还没想到怎么做。[:(]
 
procedure TForm1.Button1Click(Sender: TObject);
var
winHWND,hCur: integer;
winDC: integer;
rect: TRect;
pt: TPoint;
fBitmap: TBitmap;
begin

hCur:=GetCursor();
GetCursorPos(pt);
winHWND:=GetDeskTopWindow();
winDC:=GetDC(winHWND);
GetWindowRect(winHWND,rect);
fBitmap:=TBitmap.Create;
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);
ReleaseDC(WinHWND,winDC);
Image1.Picture.Bitmap.Assign(fBitmap);
fBitmap.Free;
end;
 
来晚不怕!说明你会,我最喜欢什么都会的人了!一样给你分!不过得少点了。
 
多人接受答案了。
 
代码:
procedure TForm1.Button3Click(Sender: TObject);
var abmp:TBitMap;
screenDC : HDC;
begin

if mediaplayer1.Mode=mpPaused then

begin

Button3.Enabled:=true;
abmp := TBitMap.Create;
with abmp, Rect(panel1.ClientTOScreen(Point(0,0)).x,panel1.ClientTOScreen(Point(0,0)).y,
panel1.ClientTOScreen(Point(0,0)).x+panel1.width,
panel1.ClientTOScreen(Point(0,0)).y +panel1.Height)do

begin

width := right - left;
height := bottom - top;
screenDC:=GetDC(0);
try
bitblt(Canvas.handle,0,0,Width,Height,ScreenDC,Left,Top,SRCCOPY);
finally
ReleaseDC(0,ScreenDC);
end;

end;

image1.Picture.Assign(abmp);
if savedialog1.Execute then

begin

image1.Picture.SaveToFile(savedialog1.filename);
end;

end;

end
 
后退
顶部