Example #1
0
        // IHTMLEditDesigner

        /*
         * This custom interface provides methods that enable clients using the editor
         * to intercept Microsoft?Internet Explorer events
         * so that they can change the editor's default behavior
         * */
        public int PreHandleEvent(int inEvtDispID, IHTMLEventObj pIEventObj)
        {
            //CGID_MSHTML
            //Guid pguidCmdGroup = new Guid("d4db6850-5385-11d0-89e9-00a0c90a90ac");
            System.Guid pguidCmdGroup        = new Guid("DE4BA900-59CA-11CF-9592-444553540000");
            onlyconnect.IOleCommandTarget ct = (onlyconnect.IOleCommandTarget) this.m_document;


            switch (inEvtDispID)
            {
            case dispids.DISPID_IHTMLELEMENT_ONCLICK:
                break;

            case dispids.DISPID_IHTMLELEMENT_ONKEYDOWN:
                break;

            case dispids.DISPID_IHTMLELEMENT_ONKEYUP:
                break;

            case dispids.DISPID_IHTMLELEMENT_ONKEYPRESS:
                break;

            case dispids.DISPID_MOUSEMOVE:
                break;

            case dispids.DISPID_MOUSEDOWN:
                break;

            case dispids.DISPID_KEYDOWN:
                //Need to trap Del here
                if (pIEventObj.keyCode == 46)
                {
                    //delete
                    // this.container.DeleteSelection();
                }

                break;

            case dispids.DISPID_KEYPRESS:
                //Gets called on keypress
                // no longer needed thanks to wndproc implementation
                // see doShortCut in HtmlEditor.cs
                container.InvokeHtmlKeyPress(ref pIEventObj);
                break;

            case dispids.DISPID_EVMETH_ONDEACTIVATE:
                break;

            default:
                // Debug.WriteLine("Eventobj: " + pIEventObj.EventType);

                break;
            }

            return(HRESULT.S_FALSE);
        }
Example #2
0
        // IHTMLEditDesigner

        /*
         * This custom interface provides methods that enable clients using the editor
         * to intercept Microsoft® Internet Explorer events
         * so that they can change the editor's default behavior
         * */
        public int PreHandleEvent(int inEvtDispID, IHTMLEventObj pIEventObj)
        {
            //CGID_MSHTML
            //Guid pguidCmdGroup = new Guid("d4db6850-5385-11d0-89e9-00a0c90a90ac");
            System.Guid pguidCmdGroup        = new Guid("DE4BA900-59CA-11CF-9592-444553540000");
            onlyconnect.IOleCommandTarget ct = (onlyconnect.IOleCommandTarget) this.m_document;

            int iRetval;

            switch (inEvtDispID)
            {
            case ComSupport.DISPID_IHTMLELEMENT_ONCLICK:
                break;

            case ComSupport.DISPID_IHTMLELEMENT_ONKEYDOWN:
                break;

            case ComSupport.DISPID_IHTMLELEMENT_ONKEYUP:
                break;

            case  ComSupport.DISPID_IHTMLELEMENT_ONKEYPRESS:
                break;

            case ComSupport.DISPID_MOUSEMOVE:
                break;

            case ComSupport.DISPID_MOUSEDOWN:
                break;

            case ComSupport.DISPID_KEYDOWN:
                //Need to trap Del here
                if (pIEventObj.keyCode == 46)
                {
                    //delete
                    if (ct != null)
                    {
                        Object pvaIn  = null;
                        Object pvaOut = null;
                        iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_DELETE, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                    }
                }

                break;

            case ComSupport.DISPID_KEYPRESS:
                Debug.WriteLine("PreHandle KeyPress -603");
                //Gets called on keypress
                //look for Ctrl-n combos
                if (pIEventObj.ctrlKey)
                {
                    int iKey = pIEventObj.keyCode;
                    switch (iKey)
                    {
                    case 1:         //CTRL-A

                        //select all
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_SELECTALL, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }


                        break;

                    case 3:         //CTRL-C
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_COPY, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }
                        break;

                    case 22:         //CTRL-V
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_PASTE, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }
                        break;

                    case 24:         //CTRL-X
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_CUT, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }
                        break;

                    case 25:         //CTRL-Y
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_REDO, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }
                        break;

                    case 26:         //CTRL-Z
                        if (ct != null)
                        {
                            Object pvaIn  = null;
                            Object pvaOut = null;
                            iRetval = ct.Exec(ref pguidCmdGroup, onlyconnect.ComSupport.IDM_UNDO, (int)onlyconnect.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);
                        }
                        break;

                    default:
                        //container.InvokeHtmlKeyPress(ref pIEventObj);
                        break;
                    }
                }
                container.InvokeHtmlKeyPress(ref pIEventObj);

                break;

            case ComSupport.DISPID_EVMETH_ONDEACTIVATE:
                break;

            default:
                break;
            }

            return(HRESULT.S_FALSE);
        }