Ejemplo n.º 1
0
 public WindowMessageEventArgs(Win32NativeWindow window, WindowMessageEnum _uMsg, IntPtr _wParam, IntPtr _lParam) : base(window)
 {
     hWnd   = (window == null) ? IntPtr.Zero : window.Handle;
     uMsg   = _uMsg;
     wParam = _wParam;
     lParam = _lParam;
 }
Ejemplo n.º 2
0
 public static void RegisterWindow(Win32NativeWindow window)
 {
     lock (Instance.Windows) {
         if (m_MainWindow == null)
         {
             m_MainWindow = window;
         }
         Instance.Windows.Add((int)window.Handle, window);
     }
 }
Ejemplo n.º 3
0
 protected void DetectMode()
 {
     Application.KeepAliveWithoutWindows = true;
     // could use full monitor width, but it may be problematic if window touches another monitor
     using (Win32NativeWindow temp_win = new Win32NativeWindow(null, X, Y, 1, 1)) {
         using (DeviceContext temp_dc = new DeviceContext(temp_win)) {
             m_BitsPerPixel = temp_dc.GetCaps(DeviceCapability.BitsPerPixel);
             m_RefreshRate  = temp_dc.GetCaps(DeviceCapability.RefreshRate);
         }
     }
     Application.KeepAliveWithoutWindows = false;
 }
Ejemplo n.º 4
0
 public static void UnregisterWindow(Win32NativeWindow window)
 {
     lock (Instance.Windows) {
         Instance.Windows.Remove((int)window.Handle);
         if (window == m_MainWindow)
         {
             IEnumerator <Win32NativeWindow> windows = Instance.Windows.Values.GetEnumerator();
             windows.Reset();
             if (windows.MoveNext())
             {
                 m_MainWindow = windows.Current;
             }
             else
             {
                 m_MainWindow = null;
             }
         }
     }
 }
        public virtual void SetWindow(Win32NativeWindow window)
        {
            if (m_Window == window)
            {
                return;
            }
            if (m_Window != null)
            {
                m_Window.CloseEvent         -= OnWindowClose;
                m_Window.ResizeEvent        -= OnWindowResize;
                m_Window.MoveEvent          -= OnWindowMove;
                m_Window.EnterSizeMoveEvent -= OnWindowEnterSizeMove;
                m_Window.ExitSizeMoveEvent  -= OnWindowExitSizeMove;
            }

            m_Window = window;

            if (m_Window != null && !m_Window.Disposed)
            {
                API.Externals.GetCursorPos(ref m_PrevMousePos);

                m_ClientRect = window.GetClientRect();                 // this only gives width and height
                Point2 point = Point2.Zero;
                API.Externals.ClientToScreen(window.Handle, ref point);
                m_ClientRect.X = point.X;
                m_ClientRect.Y = point.Y;

                m_X = m_PrevX = m_PrevMousePos.X - m_ClientRect.X;
                m_Y = m_PrevY = m_PrevMousePos.Y - m_ClientRect.Y;

                m_Window.CloseEvent         += OnWindowClose;
                m_Window.ResizeEvent        += OnWindowResize;
                m_Window.MoveEvent          += OnWindowMove;
                m_Window.EnterSizeMoveEvent += OnWindowEnterSizeMove;
                m_Window.ExitSizeMoveEvent  += OnWindowExitSizeMove;
            }
        }