When I use the magnification API to capture the image of the main screen, the callback set by MagImageScalingCallback can trigger and return data.
But when I put the host window on the secondary screen to capture the secondary screen, the contents of the secondary screen can be displayed on the host, but the callback set by MagImageScalingCallback will not be triggered.
The code is as follows:
hostWindowRect.top = -1080;
hostWindowRect.bottom = -180; // top quarter of screen
hostWindowRect.left = 0;
hostWindowRect.right = 1920;
int width = hostWindowRect.right - hostWindowRect.left;
int height = hostWindowRect.bottom - hostWindowRect.top;
// Create the host window.
RegisterHostWindowClass(hinst);
hwndHost = CreateWindowEx(WS_EX_LAYERED,
WindowClassName, WindowTitle,
RESTOREDWINDOWSTYLES,
hostWindowRect.left, hostWindowRect.top, width, height, NULL, NULL, hInst, NULL);
if (!hwndHost) {
return FALSE;
}
// Create a magnifier control that fills the client area.
magWindowRect.top = -1080;
magWindowRect.bottom = 0;
magWindowRect.left = 0;
magWindowRect.right = 1920;
width = magWindowRect.right - magWindowRect.left;
height = magWindowRect.bottom - magWindowRect.top;
hwndMag = CreateWindow(WC_MAGNIFIER, TEXT("MagnifierWindow"),
WS_CHILD | MS_SHOWMAGNIFIEDCURSOR | WS_VISIBLE,
magWindowRect.left, magWindowRect.top, width, height, hwndHost, NULL, hInst, NULL);
if (!hwndMag) {
return FALSE;
}
BOOL result = MagSetImageScalingCallback(
hwndMag,
&OnMagImageScalingCallback);
if (result) {
}
//... ...
sourceRect.top = -1080;
sourceRect.bottom = 0;
sourceRect.left = 0;
sourceRect.right = 1920;
// Set the source rectangle for the magnifier control.
MagSetWindowSource(hwndMag, sourceRect);
What is the reason that the callback is not triggered?
Or is there any way to get the image data displayed in the magnifying glass window in RGB format?
I try to use BitBlt and printwindow API, the function returns success, but the RGB is black image.