it seems to me I found a bug in procedure "CaptureFromScreen" in "imageenio.pas" module: if i do screenshot on multi-monitor computer the cursor position is not correct. Even if the cursor is situated on the second monitor, the result screenshot shows cursor only on the first monitor. What needs to be fixed in this code to correct cursor position on screenshots on the multi-monitor computers?
procedure TImageEnIO.CaptureFromScreen(Source: TIECSSource; MouseCursor: TCursor);
var
hwin, hdc: THandle;
x, y, w, h: integer;
rc: TRect;
vdsk: boolean;
pt: TPoint;
xbmp: TIEDibBitmap;
plc: TWINDOWPLACEMENT;
hCursor: THandle;
MousePt: TPoint;
ClientLeftTop: TPoint;
IconInfo: TIconInfo;
begin
// ASYNC MODE
if (not fIEBitmapCreated) and fAsyncMode and (not IsInsideAsyncThreads) then
begin
TIEIOThread.CreateCaptureFromScreen(self, CaptureFromScreen, Source, MouseCursor);
exit;
end;
if not MakeConsistentBitmap([]) then
exit;
getcursorpos(MousePt);
hCursor := Screen.Cursors[-2];
GetIconInfo(hCursor, IconInfo);
ClientLeftTop := Point(0, 0);
vdsk := (IEGlobalSettings().OpSys <> ieosWin95) and (IEGlobalSettings().OpSys <> ieosWinNT4);
hwin := 0;
w := 0;
h := 0;
x := 0;
y := 0;
case Source of
iecsScreen:
begin
hwin := GetDesktopWindow;
if vdsk then
begin
x := GetSystemMetrics(76); // SM_XVIRTUALSCREEN
y := GetSystemMetrics(77); // SM_YVIRTUALSCREEN
w := GetSystemMetrics(78); // SM_CXVIRTUALSCREEN
h := GetSystemMetrics(79); // SM_CYVIRTUALSCREEN
end
else
begin
// OLDER VERSIONS OF WINDOWS
w := Screen.Width;
h := Screen.Height;
end;
dec(MousePt.x, integer(IconInfo.xHotspot));
dec(MousePt.y, integer(IconInfo.yHotspot));
Windows.ScreenToClient(hwin, MousePt);
end;
...
if hwin <> 0 then
begin
xbmp := TIEDibBitmap.Create;
xbmp.AllocateBits(w, h, 24);
hdc := GetWindowDC(hwin);
if hdc <> 0 then
begin
BitBlt(xbmp.HDC, 0, 0, w, h, hdc, x, y, SRCCOPY);
if MouseCursor <> -1 then
DrawIconEx(xbmp.HDC, MousePt.x, MousePt.y, hCursor, 0, 0, 0, 0, DI_DEFAULTSIZE or DI_NORMAL);
fIEBitmap.Allocate(w, h, ie24RGB);
for y := 0 to h - 1 do
CopyMemory(fIEBitmap.Scanline[y], xbmp.Scanline[y], fIEBitmap.RowLen);
FreeAndNil(xbmp);
ReleaseDC(hwin, hdc);
fParams.DpiX := IEGlobalSettings().SystemDPIX;
fParams.DpiY := IEGlobalSettings().SystemDPIY;
Update;
end;
end;
DoFinishWork;
end;