Beispiel #1
0
        public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            switch (kind)
            {
            case kEventAppActivated:
            {
                foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                {
                    if (!XplatUICarbon.IsWindowVisible(utility_window))
                    {
                        XplatUICarbon.ShowWindow(utility_window);
                    }
                }
                break;
            }

            case kEventAppDeactivated:
            {
                if (XplatUICarbon.FocusWindow != IntPtr.Zero)
                {
                    Driver.SendMessage(XplatUICarbon.FocusWindow, Msg.WM_KILLFOCUS, IntPtr.Zero, IntPtr.Zero);
                }
                if (XplatUICarbon.Grab.Hwnd != IntPtr.Zero)
                {
                    Driver.SendMessage(Hwnd.ObjectFromHandle(XplatUICarbon.Grab.Hwnd).Handle, Msg.WM_LBUTTONDOWN, (IntPtr)MsgButtons.MK_LBUTTON, (IntPtr)(Driver.MousePosition.X << 16 | Driver.MousePosition.Y));
                }
                foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                {
                    if (XplatUICarbon.IsWindowVisible(utility_window))
                    {
                        XplatUICarbon.HideWindow(utility_window);
                    }
                }
                break;
            }
            }

            return(true);
        }
        public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            IntPtr window = Driver.HandleToWindow(handle);
            Hwnd   hwnd   = Hwnd.ObjectFromHandle(window);

            if (window != IntPtr.Zero)
            {
                switch (kind)
                {
                case kEventWindowActivated: {
                    Control c = Control.FromHandle(hwnd.client_window);
                    if (c != null)
                    {
                        Form form = c.FindForm();
                        if (form != null && !form.IsDisposed)
                        {
                            Driver.SendMessage(form.Handle, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_ACTIVE, IntPtr.Zero);
                            XplatUICarbon.ActiveWindow = hwnd.client_window;
                        }
                    }

                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && !XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.ShowWindow(utility_window);
                        }
                    }
                    break;
                }

                case kEventWindowExpanding:
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && !XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.ShowWindow(utility_window);
                        }
                    }
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    return(true);

                case kEventWindowExpanded:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    return(true);

                case kEventWindowDeactivated: {
                    Control c = Control.FromHandle(hwnd.client_window);
                    if (c != null)
                    {
                        Form form = c.FindForm();
                        if (form != null && XplatUICarbon.UnactiveWindow != form.Handle)
                        {
                            Driver.SendMessage(form.Handle, Msg.WM_ACTIVATE, (IntPtr)WindowActiveFlags.WA_INACTIVE, IntPtr.Zero);
                            XplatUICarbon.ActiveWindow = IntPtr.Zero;
                        }
                    }
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.HideWindow(utility_window);
                        }
                    }
                    break;
                }

                case kEventWindowCollapsing:
                    foreach (IntPtr utility_window in XplatUICarbon.UtilityWindows)
                    {
                        if (utility_window != handle && XplatUICarbon.IsWindowVisible(utility_window))
                        {
                            XplatUICarbon.HideWindow(utility_window);
                        }
                    }
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    return(true);

                case kEventWindowCollapsed:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_WINDOWPOSCHANGED, IntPtr.Zero, IntPtr.Zero);
                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    return(true);

                case kEventWindowClose:
                    NativeWindow.WndProc(hwnd.Handle, Msg.WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
                    return(false);

                case kEventWindowShown: {
                    msg.message = Msg.WM_SHOWWINDOW;
                    msg.lParam  = (IntPtr)1;
                    msg.wParam  = (IntPtr)0;
                    msg.hwnd    = hwnd.Handle;

                    return(true);
                }

                case kEventWindowResizeStarted: {
                    msg.message = Msg.WM_ENTERSIZEMOVE;
                    msg.hwnd    = hwnd.Handle;
                    return(true);
                }

                case kEventWindowResizeCompleted: {
                    msg.message = Msg.WM_EXITSIZEMOVE;
                    msg.hwnd    = hwnd.Handle;

                    return(true);
                }

                case kEventWindowBoundsChanged: {
                    Rect   window_bounds = new Rect();
                    HIRect view_bounds   = new HIRect();
                    Size   size;

                    GetWindowBounds(handle, 33, ref window_bounds);

                    view_bounds.size.width  = window_bounds.right - window_bounds.left;
                    view_bounds.size.height = window_bounds.bottom - window_bounds.top;

                    HIViewSetFrame(hwnd.WholeWindow, ref view_bounds);

                    size = XplatUICarbon.TranslateQuartzWindowSizeToWindowSize(Control.FromHandle(hwnd.Handle).GetCreateParams(), (int)view_bounds.size.width, (int)view_bounds.size.height);

                    hwnd.X      = (int)window_bounds.left;
                    hwnd.Y      = (int)window_bounds.top;
                    hwnd.Width  = (int)size.Width;
                    hwnd.Height = (int)size.Height;

                    Driver.PerformNCCalc(hwnd);

                    msg.hwnd    = hwnd.Handle;
                    msg.message = Msg.WM_WINDOWPOSCHANGED;
                    Driver.SetCaretPos(XplatUICarbon.Caret.Hwnd, XplatUICarbon.Caret.X, XplatUICarbon.Caret.Y);

                    return(true);
                }
                }
            }
            return(false);
        }