With Firemonkey 11.1, I have two employees using MacOS.
The first one
The second one
On the first one I can take screenshot of the screen of the laptop but not the external display. On the second it's the opposite.
I take screenshot like that, and I try some workaround :
LImage := CGDisplayCreateImageForRect(FID, RectToCGTrect(ACaptureRect));
if not Assigned(LImage) then
LImage := CGDisplayCreateImage(FID);
if not Assigned(LImage) then
begin
LBounds := CGDisplayBounds(FID);
LImage := CGDisplayCreateImageForRect(FID, LBounds);
end;
if not Assigned(LImage) then
begin
LBounds := CGDisplayBounds(FID);
LBounds.origin.x := 0;
LBounds.origin.y := 0;
LImage := CGDisplayCreateImageForRect(FID, LBounds);
end;
On first workstation :
First screen
FID = 0
ACaptureRect = 0, 0, 1280, 800
CGDisplayCreateImageForRect
Second screen
FID = 1
ACaptureRect = 1280, 0, 1920, 1080
CGDisplayCreateImageForRect
failedCGDisplayCreateImage(1)
failedCGDisplayBounds
failed return 0, 0, 0, 0CGDisplayBounds
#2 failed tooFull desktop (screen 1 + 2) I can take full desktop screenshot with 0, 0, 3200, 1920
On second workstation :
First screen
FID = 0
ACaptureRect = 0, 0, 1440, 900
CGDisplayCreateImageForRect
failedCGDisplayCreateImage(0)
failedCGDisplayBounds
failed return 0, 0, 1440, 900CGDisplayBounds
#2 failed too 0, 0, 1440, 900Second screen
FID = 1
ACaptureRect = 1440, 0, 1920, 1080
CGDisplayCreateImageForRect
Full desktop (screen 1 + 2) It failed as it's base on display 0 that previously failed too.
There is no logic why only laptop screen work on first workstation, and only external display work on second laptop.
Both have app open on the same screen (on the laptop)
The difference, it that on second laptop (on Monterey), even when I can't take laptop screen, CGDisplayBounds
return the good size.
I'm out of idea and workaround
EDIT : On same laptop of second workstation, but in BigSur version (not Monterey) all working well ! That's insane
@ptitBoss: Your FID is simple not good, you retrieve it in the wrong way. Use functions like CGGetOnlineDisplayList
, CGGetActiveDisplayList
, etc.