请问谁知道在抓屏幕时把鼠标抓下? 哪位高手指点一下! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ////Mybmp: 用于保存图像//DrawCur: 是否抓鼠标//procedure GetCurrentScreen(var Mybmp: TBitmap; DrawCur: Boolean);var Cursorx, Cursory: integer; dc: hdc; Mycan: Tcanvas; R: TRect; DrawPos: TPoint; MyCursor: TIcon; hld: hwnd; Threadld: dword; mp: tpoint; pIconInfo: TIconInfo;begin Mybmp := Tbitmap.Create; //建立BMPMAP Mycan := TCanvas.Create; //屏幕截取 dc := GetWindowDC(0);//取屏幕DC Try Mycan.Handle := dc; R := Rect(0, 0, screen.Width, screen.Height); Mybmp.Width := R.Right; Mybmp.Height := R.Bottom; Mybmp.Canvas.CopyRect(R, Mycan, R); Finally ReleaseDC(0, DC); end; Mycan.Handle := 0; Mycan.Free; if DrawCur then {画上鼠标图象} begin GetCursorPos(DrawPos);//取鼠标位置 MyCursor := TIcon.Create; GetCursorPos(mp); hld := WindowFromPoint(mp); Threadld := GetWindowThreadProcessId(hld, nil); AttachThreadInput(GetCurrentThreadId, Threadld, True); MyCursor.Handle := Getcursor(); AttachThreadInput(GetCurrentThreadId, threadld, False); GetIconInfo(Mycursor.Handle, pIconInfo); cursorx := DrawPos.x - round(pIconInfo.xHotspot); cursory := DrawPos.y - round(pIconInfo.yHotspot); Mybmp.Canvas.Draw(cursorx, cursory, MyCursor); {画上鼠标} DeleteObject(pIconInfo.hbmColor); //GetIconInfo 使用时创建了两个bitmap对象. 需要手工释放这两个对象 DeleteObject(pIconInfo.hbmMask); //否则,调用他后,他会创建一个bitmap,多次调用会产生多个,直至资源耗尽 Mycursor.ReleaseHandle; //释放数组内存 MyCursor.Free; //释放鼠标指针 end;end; 有一定难度:如何修改(替换)类的只读属性? 如何删除XML中都某节点? WebBro wser 关于 ipv6 的讨论,参与者有分。 求变量ascii的递增值 斑竹!!!昨天我答了问题,并已解贴为何不给我加分???? 菜鸟问题,关于消息的,高手过来看! 简单问题~~~~来抢分阿,在线 C语言中的GZIPInputStream在DELPHI可用什么表示? 关于给paradox建索引的问题 如何在DEPHI的录入界面作成EXCEL式的录入方式?? 我要找一个dxcomnd6组件的D7控件下载,请问哪里有下啊,请给说明一个地址,谢谢!
//Mybmp: 用于保存图像
//DrawCur: 是否抓鼠标
//
procedure GetCurrentScreen(var Mybmp: TBitmap; DrawCur: Boolean);
var
Cursorx, Cursory: integer;
dc: hdc;
Mycan: Tcanvas;
R: TRect;
DrawPos: TPoint;
MyCursor: TIcon;
hld: hwnd;
Threadld: dword;
mp: tpoint;
pIconInfo: TIconInfo;
begin
Mybmp := Tbitmap.Create; //建立BMPMAP
Mycan := TCanvas.Create; //屏幕截取
dc := GetWindowDC(0);//取屏幕DC
Try
Mycan.Handle := dc;
R := Rect(0, 0, screen.Width, screen.Height);
Mybmp.Width := R.Right;
Mybmp.Height := R.Bottom;
Mybmp.Canvas.CopyRect(R, Mycan, R);
Finally
ReleaseDC(0, DC);
end;
Mycan.Handle := 0;
Mycan.Free;
if DrawCur then {画上鼠标图象}
begin
GetCursorPos(DrawPos);//取鼠标位置
MyCursor := TIcon.Create;
GetCursorPos(mp);
hld := WindowFromPoint(mp);
Threadld := GetWindowThreadProcessId(hld, nil);
AttachThreadInput(GetCurrentThreadId, Threadld, True);
MyCursor.Handle := Getcursor();
AttachThreadInput(GetCurrentThreadId, threadld, False);
GetIconInfo(Mycursor.Handle, pIconInfo);
cursorx := DrawPos.x - round(pIconInfo.xHotspot);
cursory := DrawPos.y - round(pIconInfo.yHotspot);
Mybmp.Canvas.Draw(cursorx, cursory, MyCursor); {画上鼠标}
DeleteObject(pIconInfo.hbmColor);
//GetIconInfo 使用时创建了两个bitmap对象. 需要手工释放这两个对象
DeleteObject(pIconInfo.hbmMask);
//否则,调用他后,他会创建一个bitmap,多次调用会产生多个,直至资源耗尽
Mycursor.ReleaseHandle; //释放数组内存
MyCursor.Free; //释放鼠标指针
end;
end;