Advertisement
Guest User

Untitled

a guest
Jul 30th, 2012
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Interop;
  6. using System.Runtime.InteropServices;
  7. using Core;
  8.  
  9. namespace MagnifierControl
  10. {
  11.      public  class ControlHost : HwndHost
  12.      {
  13.          IntPtr hwndControl;
  14.          IntPtr hwndHost;
  15.          int hostHeight, hostWidth;
  16.  
  17.  
  18.          public  ControlHost(double height,double width)
  19.          {
  20.              hostHeight = (int)height;
  21.              hostWidth = (int)width;
  22.          }
  23.  
  24.          protected override HandleRef BuildWindowCore(HandleRef hwndParent)
  25.          {
  26.              hwndControl = IntPtr.Zero;
  27.              hwndHost = IntPtr.Zero;
  28.  
  29.              hwndHost = Native.CreateWindowEx(0,"MagnifierHost","",
  30.                                 (int)Native.WindowStyles.WS_CHILD | (int)Native.WindowStyles.WS_VISIBLE ,
  31.                                 0,0,
  32.                                 hostWidth,hostHeight,
  33.                                 hwndParent.Handle,
  34.                                 IntPtr.Zero,
  35.                                 IntPtr.Zero,
  36.                                 IntPtr.Zero);
  37.  
  38.  
  39.              hwndControl = Native.CreateWindowEx(0, "Magnifier", Native.WC_MAGNIFIER,
  40.                             (int)Native.WindowStyles.WS_CHILD | (int)Native.WindowStyles.WS_VISIBLE | (int)Native.MagnifierStyle.MS_CLIPAROUNDCURSOR,
  41.                             0, 0, hostWidth, hostHeight,
  42.                             hwndHost,
  43.                             IntPtr.Zero,
  44.                             Native.GetModuleHandle(null),
  45.                             IntPtr.Zero);
  46.  
  47.  
  48.              return new HandleRef(this, hwndControl);
  49.  
  50.          }
  51.  
  52.          protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
  53.          {
  54.              handled = false;
  55.              return IntPtr.Zero;
  56.          }
  57.  
  58.          protected override void DestroyWindowCore(HandleRef hwnd)
  59.          {
  60.              Native.DestroyWindow(hwnd.Handle);
  61.          }
  62.  
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement