Ejemplo n.º 1
0
        private void InstallHTMLHooksForOnchange()
        {
            // Install onchange hook for <input type=password, text, file>.
            String       searchCondition    = String.Format("{0}!=1", CatStudioConstants.HOOKED_BY_REC_ATTR);
            IElementList inputElemNotHooked = this.twebstBrowser.FindAllElements("input", searchCondition);

            for (int i = 0; i < inputElemNotHooked.length; ++i)
            {
                IHTMLElement2 crntNativeElem2 = (IHTMLElement2)inputElemNotHooked[i].nativeElement;
                String        inputType       = ((IHTMLInputElement)crntNativeElem2).type.ToLower();
                IHTMLElement  crntElem        = (IHTMLElement)crntNativeElem2;

                if (("text" == inputType) || ("password" == inputType) || ("file" == inputType))
                {
                    IHTMLWindow2 wnd = ((IHTMLDocument2)crntElem.document).parentWindow;
                    crntNativeElem2.attachEvent("onchange", new HtmlHandler(this.OnHtmlChange, wnd));
                }

                crntElem.setAttribute(CatStudioConstants.HOOKED_BY_REC_ATTR, "1", 0);
            }

            // Install onchange hook for <select>.
            IElementList selectElemNotHooked = this.twebstBrowser.FindAllElements("select", searchCondition);

            InstalHTMLHookOnList(selectElemNotHooked, "onchange");

            // Install onchange hook for <textarea>.
            IElementList textAreaElemNotHooked = this.twebstBrowser.FindAllElements("textarea", searchCondition);

            InstalHTMLHookOnList(textAreaElemNotHooked, "onchange");
        }
Ejemplo n.º 2
0
        public static HtmlEventProxy Create(string eventName, object htmlElement, EventHandler eventHandler)
        {
            IHTMLElement2 elem = (IHTMLElement2)htmlElement;

            HtmlEventProxy newProxy = new HtmlEventProxy(eventName, elem, eventHandler);

            elem.attachEvent(eventName, newProxy);
            return(newProxy);
        }
        public static HtmlEventObject SubscribeTo(this IHTMLElement2 element, HtmlEvents eventType, HtmlEventObject handlerObj)
        {
            try
            {
                element?.attachEvent(eventType.Name(), handlerObj);
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }

            return(handlerObj);
        }
Ejemplo n.º 4
0
        private void InstalHTMLHookOnList(IElementList elemList, String evtName)
        {
            for (int i = 0; i < elemList.length; ++i)
            {
                IHTMLElement2 crntNativeElem2 = (IHTMLElement2)elemList[i].nativeElement;
                IHTMLElement  crntElem        = (IHTMLElement)crntNativeElem2;
                IHTMLWindow2  wnd             = ((IHTMLDocument2)crntElem.document).parentWindow;

                crntNativeElem2.attachEvent(evtName, new HtmlHandler(this.OnHtmlChange, wnd));
                crntElem.setAttribute(CatStudioConstants.HOOKED_BY_REC_ATTR, "1", 0);
            }
        }
        public static bool SubscribeTo(this IHTMLElement2 element, EventType eventType, IControlHtmlEvent handlerObj)
        {
            try
            {
                return(element.IsNull()
          ? false
          : element.attachEvent(eventType.Name(), handlerObj));
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }

            return(false);
        }
        public static bool SubscribeTo(this IHTMLElement2 element, string @event, object pdisp)
        {
            try
            {
                return(element.IsNull()
          ? false
          : element.attachEvent(@event, pdisp));
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }

            return(false);
        }