Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Interop;
- using System.Runtime.InteropServices;
- using Core;
- namespace MagnifierControl
- {
- public class ControlHost : HwndHost
- {
- IntPtr hwndControl;
- IntPtr hwndHost;
- int hostHeight, hostWidth;
- public ControlHost(double height,double width)
- {
- hostHeight = (int)height;
- hostWidth = (int)width;
- }
- protected override HandleRef BuildWindowCore(HandleRef hwndParent)
- {
- hwndControl = IntPtr.Zero;
- hwndHost = IntPtr.Zero;
- hwndHost = Native.CreateWindowEx(0,"MagnifierHost","",
- (int)Native.WindowStyles.WS_CHILD | (int)Native.WindowStyles.WS_VISIBLE ,
- 0,0,
- hostWidth,hostHeight,
- hwndParent.Handle,
- IntPtr.Zero,
- IntPtr.Zero,
- IntPtr.Zero);
- hwndControl = Native.CreateWindowEx(0, "Magnifier", Native.WC_MAGNIFIER,
- (int)Native.WindowStyles.WS_CHILD | (int)Native.WindowStyles.WS_VISIBLE | (int)Native.MagnifierStyle.MS_CLIPAROUNDCURSOR,
- 0, 0, hostWidth, hostHeight,
- hwndHost,
- IntPtr.Zero,
- Native.GetModuleHandle(null),
- IntPtr.Zero);
- return new HandleRef(this, hwndControl);
- }
- protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
- {
- handled = false;
- return IntPtr.Zero;
- }
- protected override void DestroyWindowCore(HandleRef hwnd)
- {
- Native.DestroyWindow(hwnd.Handle);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement