捕获屏幕时,如何连带光标一起捕获?
捕获屏幕时,如何连带光标一起捕获?
或者,是用别的方法来实现。
请各位大大,帮帮忙。
[解决办法]
function GetCursorHandle: HCURSOR;
var
hWindow : HWND;
pt : TPoint;
pIconInfo : TIconInfo;
dwThreadID, dwCurrentThreadID: DWORD;
begin
// Find out which window owns the cursor
GetCursorPos(pt);
hWindow := WindowFromPoint(pt);
// Get the thread ID for the cursor owner.
dwThreadID := GetWindowThreadProcessId(hWindow, nil);
// Get the thread ID for the current thread
dwCurrentThreadID := GetCurrentThreadId;
// If the cursor owner is not us then we must attach to
// the other thread in so that we can use GetCursor() to
// return the correct hCursor
if (dwCurrentThreadID <> dwThreadID) then
begin
if AttachThreadInput(dwCurrentThreadID, dwThreadID, True) then
begin
// Get the handle to the cursor
Result := GetCursor;
AttachThreadInput(dwCurrentThreadID, dwThreadID, False);
end;
end
else
begin
Result := GetCursor;
end;
end;
procedure TForm1.btn2Click(Sender: TObject);
var
CurPosX, CurPoxY : Integer;
MyCursor : TIcon;
pIconInfo : TIconInfo;
begin
MyCursor := TIcon.Create;
try
MyCursor.Handle := GetCursorHandle;
// Retrieves information about the specified cursor.
GetIconInfo(MyCursor.Handle, pIconInfo);
CurPosX := pIconInfo.xHotspot;
CurPoxY := pIconInfo.yHotspot;
// Draw the Cursor on the form
Canvas.Draw(10, 20, MyCursor);
finally
MyCursor.ReleaseHandle;
MyCursor.Free;
end;
end;
[解决办法]
mark,收藏
[解决办法]
mark
[解决办法]
楼主可以结帖了。
[解决办法]
jiefen