Windows Magnifier Window Cause exception when setting MagSetImageScalingCallback

两盒软妹~` 提交于 2020-12-07 06:08:12

问题


I have been using a magnifier code from this github link : Magnify
I am trying to set MagImageScaling callback and i was able to get the bitmap through this callback.

Once the MagImageScaling Callback is set and if i try to move the window the the right side of the desktop. The Program throws an exception like this:

Exception thrown at 0x00007FFDA8724452 (msvcrt.dll) in Magnify10.exe: 0xC0000005: Access violation reading location 0x000001749E708FA4.


I'm not posting the complete code because it's too large.

The Callback Definition

BOOL MagImageScaling(HWND hwnd, void* srcdata, MAGIMAGEHEADER srcheader, void* destdata, MAGIMAGEHEADER destheader, RECT unclipped, RECT clipped, HRGN dirty)
{
    //Here i was able to receive the bitmap through srcdata
    return TRUE;
}

This is how i set the callback:

if (!MagSetImageScalingCallback(magActive->GetHandle(), (MagImageScalingCallback)MagImageScaling))
{
   return FALSE;
}

The above diagram shows the actual problem:

The yellow frame is the host window.
The Green frame is the magnifier window which is a child of host window.
The RED frame is the desktop rect.
The blue line is a random boundary.

When the window crosses the blue boundary it causes exception.

I think when the Window is moved, the magnifier window resizes itself and try to cross the Blue Boundary and Desktop boundary which causes this issue.

so i think if we were able to identify when the MagnifyWindow touching the desktop boundary and stop the movement of Mangnifier window then we might be able to stop it.

So is there any way to achieve this?

Here is the complete code of the project to reproduce this issue:
Magnify Bug Project

来源:https://stackoverflow.com/questions/64318817/windows-magnifier-window-cause-exception-when-setting-magsetimagescalingcallback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!