ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CaptureFromScreen cursor
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Vanes

2 Posts

Posted - Mar 05 2019 :  03:47:27  Show Profile  Reply
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;



xequte

38616 Posts

Posted - Mar 05 2019 :  16:06:12  Show Profile  Reply
Hi

I cannot reproduce that on my multi-monitor system using:

ImageEnView1.IO.CaptureFromScreen(iecsScreen, crDefault);

Can you give me more specific steps to reproduce?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Vanes

2 Posts

Posted - Mar 06 2019 :  04:21:56  Show Profile  Reply
I used this: ImageEnIO.CaptureFromScreen(iecsScreen, 1);
Go to Top of Page

xequte

38616 Posts

Posted - Mar 06 2019 :  23:00:34  Show Profile  Reply
Hi

Yes, that works for me too. Perhaps your monitors are configured in a non-standard way. Is there anything else I can try?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: