Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Disable Events of HTMLElement

Disable Events of HTMLElement

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmlquestion
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vikrant kpr
    wrote on last edited by
    #1

    Hey Friends Is it possible to disable events of a HTMLElement? Let's say in html code, there are events defined for some html elements Let's say [Click Here](some link) Now i host a webbrowser in my dialog based app and i do not want custom onselect event to be fired(i.e something here above) may be something we can do with IHTMLElement * pElem = NULL; IHTMLElement2 * pElem2 = NULL; IHTMLElement3 * pElem3 = NULL; all above interfaces have put_ functions but if i pass NULL, it means to them default behavior (i.e onselect="something here") or i can define function in my .cpp file to be called i do not want any of the above i just want htmlelement not to call onselect="something here" that's it Any Ideas? Regards

    L 1 Reply Last reply
    0
    • V vikrant kpr

      Hey Friends Is it possible to disable events of a HTMLElement? Let's say in html code, there are events defined for some html elements Let's say [Click Here](some link) Now i host a webbrowser in my dialog based app and i do not want custom onselect event to be fired(i.e something here above) may be something we can do with IHTMLElement * pElem = NULL; IHTMLElement2 * pElem2 = NULL; IHTMLElement3 * pElem3 = NULL; all above interfaces have put_ functions but if i pass NULL, it means to them default behavior (i.e onselect="something here") or i can define function in my .cpp file to be called i do not want any of the above i just want htmlelement not to call onselect="something here" that's it Any Ideas? Regards

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There isn't one place where all events are received. You can only divert one event at a time if you want to deal with events. However, IHTMLElement3 has disabled attribute that you can set to TRUE. This will disable any interaction with that IHTMLElement. Of course, first you have to reach that element. Other than that you can set the parent window as disabled and then you would not be able to do anything with that HTML control.

      V 1 Reply Last reply
      0
      • L Lost User

        There isn't one place where all events are received. You can only divert one event at a time if you want to deal with events. However, IHTMLElement3 has disabled attribute that you can set to TRUE. This will disable any interaction with that IHTMLElement. Of course, first you have to reach that element. Other than that you can set the parent window as disabled and then you would not be able to do anything with that HTML control.

        V Offline
        V Offline
        vikrant kpr
        wrote on last edited by
        #3

        hi thanks for the help i do not want to disable complete html element i just want to disable a specific dhtml event onclick, onfocus seperately

        L 1 Reply Last reply
        0
        • V vikrant kpr

          hi thanks for the help i do not want to disable complete html element i just want to disable a specific dhtml event onclick, onfocus seperately

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Use detachEvent but you have to find the event first.

          V 2 Replies Last reply
          0
          • L Lost User

            Use detachEvent but you have to find the event first.

            V Offline
            V Offline
            vikrant kpr
            wrote on last edited by
            #5

            yeah thanks will try it now and will update

            1 Reply Last reply
            0
            • L Lost User

              Use detachEvent but you have to find the event first.

              V Offline
              V Offline
              vikrant kpr
              wrote on last edited by
              #6

              IHTMLElement * pElem; IHTMLElement2 * pElem2; //Get pElem & pElem2 CString vl_sHelper("onclick"); COleVariant vl_oOnClick; pElem->get_onmouseover(&vl_oOnClick);// This should get the onclick event? pElem2->detachEvent(vl_sHelper.AllocSysString(),vl_oOnClick);//COleVariant to IDispatch* sounds strange to compiler

              L 1 Reply Last reply
              0
              • V vikrant kpr

                IHTMLElement * pElem; IHTMLElement2 * pElem2; //Get pElem & pElem2 CString vl_sHelper("onclick"); COleVariant vl_oOnClick; pElem->get_onmouseover(&vl_oOnClick);// This should get the onclick event? pElem2->detachEvent(vl_sHelper.AllocSysString(),vl_oOnClick);//COleVariant to IDispatch* sounds strange to compiler

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                It does because it is. Why COleVariant, can't you use VARIANT of type VT_DISPATCH? It is easier. And pElem and pElem2 should be the same element.

                V 2 Replies Last reply
                0
                • L Lost User

                  It does because it is. Why COleVariant, can't you use VARIANT of type VT_DISPATCH? It is easier. And pElem and pElem2 should be the same element.

                  V Offline
                  V Offline
                  vikrant kpr
                  wrote on last edited by
                  #8

                  yeah thanks compiled and ran successfully detachEvent returns SUCCESS however, seems something is missing it still calls the event written in html :-(

                  1 Reply Last reply
                  0
                  • L Lost User

                    It does because it is. Why COleVariant, can't you use VARIANT of type VT_DISPATCH? It is easier. And pElem and pElem2 should be the same element.

                    V Offline
                    V Offline
                    vikrant kpr
                    wrote on last edited by
                    #9

                    hey buddy thanks for the help found a workaround 1st find out the event then get outer html modify outer html put it back not good but works

                    L 1 Reply Last reply
                    0
                    • V vikrant kpr

                      hey buddy thanks for the help found a workaround 1st find out the event then get outer html modify outer html put it back not good but works

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      It is not a bad solution. However, detachEvent should work as well. It works if you would write from JavaScript code in HTML page. But, any solution is a good solution as long as it does the job efficiently. :)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups