Magnification API can work well when used to capture primary screen, but when i use it to capture sub screen,after MagSetWindowSource()
called, MagSetImageScalingCallback()
not triggerd.
I checked the window position is set correctly, in my computer is {-1080, -250, 0, 1670}, and i showed the window, it placed on the right position.
I use the following code to get sub screenshot, just same with the webrtc code, but MagSetImageScalingCallback()
not triggerd.
// Create the host window.
host_window_ = CreateWindowExW(WS_EX_LAYERED, kMagnifierHostClass,
kHostWindowName, 0, 0,
0, 0, 0, nullptr, nullptr, hInstance, nullptr);
// Create the magnifier control.
magnifier_window_ = CreateWindowW(kMagnifierWindowClass,
kMagnifierWindowName,
WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
host_window_, nullptr, hInstance, nullptr);
BOOL result = SetWindowPos(magnifier_window_, NULL, rect.left(), rect.top(),
rect.width(), rect.height(), 0);
// value is -1080, -250, 0, 1670
RECT native_rect = {rect.left(), rect.top(), rect.right(), rect.bottom()};
result = set_window_source_func_(magnifier_window_, native_rect);
The working environment is Windows 10 Professional 64bit, my application is also 64bit, my primary screen is plugged in discrete graphics card, sub screen is plugged in integrated graphics.
I test the code of webrtc screen_capturer_win_magnifier.cc
, find that if you want use magnification API to capture sub screen, maybe you should satisfy following conditions:
left
of host_window_ and magnifier_window_ is zerotop
of host_window_ and magnifier_window_ is zeroFor example:
{-1920, -250, 1920(width), 1080(height)}
{1920, 250, 1920(width), 1080(height)}
Have a try, good luck to you!