public bool ProcessMessage(IntPtr hwnd, UInt32 message, UInt32 wParam, UInt32 lParam, UInt32 time, Int32 xPos, Int32 yPos)
        {
            switch (message)
            {
            case WM_KEYDOWN:
            case WM_SYSKEYDOWN:
            {
                Keys keyPress = CommandHandling.GetMenuShortcutFromVirtualKey(wParam);

                if (keyPress == Keys.Return)
                {
                    // Handle <enter> manually because the default handling
                    // appears to fail when we are hosted in a win32 modal dialog
                    IntPtr hwndFind = FindWindowEx(WebBrowser.Handle, IntPtr.Zero, "Shell Embedding", "");
                    hwndFind = FindWindowEx(hwndFind, IntPtr.Zero, "Shell DocObject View", "");
                    hwndFind = FindWindowEx(hwndFind, IntPtr.Zero, "Internet Explorer_Server", "");

                    if (hwndFind != null)
                    {
                        SendMessage(hwndFind, WM_CHAR, VK_RETURN, 0);
                    }

                    return(true);
                }
                else if (keyPress != Keys.None)
                {
                    return(base.OnDocumentKeyPress(keyPress));
                }
            }
            break;
            }

            return(false);
        }
Example #2
0
        public bool ProcessMessage(IntPtr hwnd, UInt32 message, UInt32 wParam, UInt32 lParam, UInt32 time, Int32 xPos, Int32 yPos)
        {
            if (!ReadOnly)
            {
                switch (message)
                {
                case WM_KEYDOWN:
                case WM_SYSKEYDOWN:
                {
                    Keys keyPress = CommandHandling.GetMenuShortcutFromVirtualKey(wParam);

                    if (keyPress == Keys.Return)
                    {
                        // Handle <enter> manually because the default handling
                        // appears to fail when we are hosted in a win32 modal dialog
                        IntPtr hwndFind = FindWindowEx(WebBrowser.Handle, IntPtr.Zero, "Shell Embedding", "");
                        hwndFind = FindWindowEx(hwndFind, IntPtr.Zero, "Shell DocObject View", "");
                        hwndFind = FindWindowEx(hwndFind, IntPtr.Zero, "Internet Explorer_Server", "");

                        if (hwndFind != null)
                        {
                            SendMessage(hwndFind, WM_CHAR, VK_RETURN, 0);
                        }

                        return(true);
                    }
                    else if (keyPress != Keys.None)
                    {
                        return(OnDocumentKeyPress(keyPress));
                    }
                }
                break;

                case WM_CHAR:
                    if ((wParam == '@') && (NeedAttributeValues != null))
                    {
                        // Can't handle this with WM_KEYDOWN because different
                        // keyboard layouts place '@' in different locations
                        var items = GetPopupListBoxItems();

                        if (items.Count() > 0)
                        {
                            // Insert the '@' first and select it
                            SelectedHtml = "@";
                            SelectCharacterAtCaret(false);

                            var popup = new PopupListBox();

                            popup.ListBox.Items.AddRange(items);
                            popup.ListBox.Font = m_ControlsFont;

                            popup.Closed += new ToolStripDropDownClosedEventHandler(OnAttributeListBoxClosed);

                            var pos = GetPopupListBoxLocation();
                            popup.Show(pos.X, pos.Y);

                            return(true);                            // we already added the '@'
                        }
                    }
                    break;
                }
            }

            return(false);
        }