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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CaptureFromScreen cursor

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Vanes Posted - Mar 05 2019 : 03:47:27
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;



3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 06 2019 : 23:00:34
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
Vanes Posted - Mar 06 2019 : 04:21:56
I used this: ImageEnIO.CaptureFromScreen(iecsScreen, 1);
xequte Posted - Mar 05 2019 : 16:06:12
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