private void SetupMagnifier() { if (!initialized) return; IntPtr hInst; hInst = NativeMethods.GetModuleHandle(null); // Make the window opaque. Which has been dealt with in the magnifier class //form.AllowTransparency = true; //form.TransparencyKey = Color.Empty; //form.Opacity = 255; // Create a magnifier control that fills the client area. NativeMethods.GetClientRect(form.Handle, ref magWindowRect); if (isLens)// if the magnifier is a lens don't show magnifier cursor { hwndMag = NativeMethods.CreateWindow((int)ExtendedWindowStyles.WS_EX_CLIENTEDGE, NativeMethods.WC_MAGNIFIER, "MagnifierWindow", (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_VISIBLE, magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, form.Handle, IntPtr.Zero, hInst, IntPtr.Zero); } else// if the magnifier is not a lens show the maginified cursor { hwndMag = NativeMethods.CreateWindow((int)ExtendedWindowStyles.WS_EX_CLIENTEDGE, NativeMethods.WC_MAGNIFIER, "MagnifierWindow", (int)WindowStyles.WS_CHILD | (int)MagnifierStyle.MS_SHOWMAGNIFIEDCURSOR | (int)WindowStyles.WS_VISIBLE, magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, form.Handle, IntPtr.Zero, hInst, IntPtr.Zero); } //initialStyle = NativeMethods.GetWindowLong(hwndMag, -20); //NativeMethods.SetWindowLong(hwndMag, -20, initialStyle | 0x80000 | 0x20); //NativeMethods.SetLayeredWindowAttributes(hwndMag, 0, 255, LayeredWindowAttributeFlags.LWA_ALPHA); if (hwndMag == IntPtr.Zero) { return; } // Set the magnification factor. Transformation matrix = new Transformation(magnification); NativeMethods.MagSetWindowTransform(hwndMag, ref matrix); }
public void setMagnificationFactor() { Transformation matrix = new Transformation(magnification); NativeMethods.MagSetWindowTransform(hwndMag, ref matrix); }
private void SetupMagnifier() { if (!initialized) { return; } IntPtr hInst; hInst = NativeMethods.GetModuleHandle(null); // Make the window opaque. Which has been dealt with in the magnifier class //form.AllowTransparency = true; //form.TransparencyKey = Color.Empty; //form.Opacity = 255; // Create a magnifier control that fills the client area. NativeMethods.GetClientRect(form.Handle, ref magWindowRect); /* * if (isLens)// if the magnifier is a lens don't show magnifier cursor * { * hwndMag = NativeMethods.CreateWindow((int)ExtendedWindowStyles.WS_EX_CLIENTEDGE, NativeMethods.WC_MAGNIFIER, * "MagnifierWindow", (int)WindowStyles.WS_CHILD | * (int)WindowStyles.WS_VISIBLE, * magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, form.Handle, IntPtr.Zero, hInst, IntPtr.Zero); * } * else// if the magnifier is not a lens show the maginified cursor*/ //{ // show mainified cursor hwndMag = NativeMethods.CreateWindow((int)ExtendedWindowStyles.WS_EX_CLIENTEDGE, NativeMethods.WC_MAGNIFIER, "MagnifierWindow", (int)WindowStyles.WS_CHILD | (int)MagnifierStyle.MS_SHOWMAGNIFIEDCURSOR | (int)WindowStyles.WS_VISIBLE, magWindowRect.left, magWindowRect.top, magWindowRect.right, magWindowRect.bottom, form.Handle, IntPtr.Zero, hInst, IntPtr.Zero); // } if (hwndMag == IntPtr.Zero) { return; } // Set the magnification factor. Transformation matrix = new Transformation(magnification); NativeMethods.MagSetWindowTransform(hwndMag, ref matrix); NativeMethods.GetCursorPos(ref mousePoint); int width = (int)((magWindowRect.right - magWindowRect.left) / magnification); int height = (int)((magWindowRect.bottom - magWindowRect.top) / magnification); // the size of the sourceRect //int width = 250; //int height = 250; //Set the area around the mouse to sourceRect. //and adjust this sourceRect if the sourceRect is over the region of the screen. if (mousePoint.x - width / 2 < 0) { sourceRect.left = 0; } else { sourceRect.left = mousePoint.x - width / 2; } if (mousePoint.y - height / 2 < 0) { sourceRect.top = 0; } else { sourceRect.top = mousePoint.y - height / 2; } sourceRect.right = mousePoint.x + width / 2; sourceRect.bottom = mousePoint.y + height / 2; }
public static extern bool MagSetWindowTransform(IntPtr hwnd, ref Transformation pTransform);