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. Having trouble with IOleCommandTarget interface

Having trouble with IOleCommandTarget interface

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • H Offline
    H Offline
    Haim Nachum
    wrote on last edited by
    #1

    hi. ive implemented a simple bho object with an IOleCommandTarget interface. i have my Exec method and its called upon a click event of a toolbar button ive added to IE. the method looks like that :

    STDMETHODIMP CHelloWorldBHO::Exec(const GUID *pguidCmdGroup,
    DWORD nCmdID, DWORD nCmdExecOpt,
    VARIANTARG *pvaIn, VARIANTARG *pvaOut)
    {

    HRESULT hr = S\_OK;
    HWND hwnd;
    if(m\_spWebBrowser!=NULL)
    HRESULT hr1 = m\_spWebBrowser->get\_HWND((LONG\_PTR\*)&hwnd);
     else
           {
             MessageBox(NULL, \_T("No Web browser pointer"), \_T("Oops"), 0);
           }
    
    
    return hr;
    

    }

    it always displays the "No Web browser pointer" message. it seems my spWebBrowser variable is null even though ive implemented SetSite method. i know that SetSite is fired when IE loads because im handeling an event of IE and it works fine. my button is registerd in :

    HKLM {
    NoRemove SOFTWARE
    {
    NoRemove Microsoft
    {
    NoRemove 'Internet Explorer'
    {
    NoRemove Extensions
    {
    ForceRemove '{5D578929-E74E-46A2-A810-4F33D011DC51}'
    = s 'PageCop' {
    val 'Default Visible' = s 'yes'
    val 'ButtonText' = s 'Inspect page'
    val 'CLSID' = s '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}'
    val 'ClsidExtension' =
    s '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}'
    val 'Icon' = s 'C:\icons\WinXP\search4doc.ico'
    val 'HotIcon' = s 'C:\ icons\WinXP\search4doc.ico'
    }
    }
    }
    }
    }
    }

    my bho is registerd in :

    HKLM {
    NoRemove SOFTWARE {
    NoRemove Microsoft {
    NoRemove Windows {
    NoRemove CurrentVersion {
    NoRemove Explorer {
    NoRemove 'Browser Helper Objects' {
    ForceRemove '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}' = s 'HelloWorldBHO' {
    val 'NoExplorer' = d '1'
    }
    }
    }
    }
    }
    }
    }
    }

    anyone knows thats the problem?

    _ 1 Reply Last reply
    0
    • H Haim Nachum

      hi. ive implemented a simple bho object with an IOleCommandTarget interface. i have my Exec method and its called upon a click event of a toolbar button ive added to IE. the method looks like that :

      STDMETHODIMP CHelloWorldBHO::Exec(const GUID *pguidCmdGroup,
      DWORD nCmdID, DWORD nCmdExecOpt,
      VARIANTARG *pvaIn, VARIANTARG *pvaOut)
      {

      HRESULT hr = S\_OK;
      HWND hwnd;
      if(m\_spWebBrowser!=NULL)
      HRESULT hr1 = m\_spWebBrowser->get\_HWND((LONG\_PTR\*)&hwnd);
       else
             {
               MessageBox(NULL, \_T("No Web browser pointer"), \_T("Oops"), 0);
             }
      
      
      return hr;
      

      }

      it always displays the "No Web browser pointer" message. it seems my spWebBrowser variable is null even though ive implemented SetSite method. i know that SetSite is fired when IE loads because im handeling an event of IE and it works fine. my button is registerd in :

      HKLM {
      NoRemove SOFTWARE
      {
      NoRemove Microsoft
      {
      NoRemove 'Internet Explorer'
      {
      NoRemove Extensions
      {
      ForceRemove '{5D578929-E74E-46A2-A810-4F33D011DC51}'
      = s 'PageCop' {
      val 'Default Visible' = s 'yes'
      val 'ButtonText' = s 'Inspect page'
      val 'CLSID' = s '{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}'
      val 'ClsidExtension' =
      s '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}'
      val 'Icon' = s 'C:\icons\WinXP\search4doc.ico'
      val 'HotIcon' = s 'C:\ icons\WinXP\search4doc.ico'
      }
      }
      }
      }
      }
      }

      my bho is registerd in :

      HKLM {
      NoRemove SOFTWARE {
      NoRemove Microsoft {
      NoRemove Windows {
      NoRemove CurrentVersion {
      NoRemove Explorer {
      NoRemove 'Browser Helper Objects' {
      ForceRemove '{A414425C-2E84-4CA3-B7F0-BCA49A9F89D6}' = s 'HelloWorldBHO' {
      val 'NoExplorer' = d '1'
      }
      }
      }
      }
      }
      }
      }
      }

      anyone knows thats the problem?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Make sure you are assigning m_spWebBrowser in the SetSite function by doing a QueryInterface on the passed in IUnknown pointer.

      «_Superman_»

      H 1 Reply Last reply
      0
      • _ _Superman_

        Make sure you are assigning m_spWebBrowser in the SetSite function by doing a QueryInterface on the passed in IUnknown pointer.

        «_Superman_»

        H Offline
        H Offline
        Haim Nachum
        wrote on last edited by
        #3

        im sure that m_spWebBrowser is assigned because im handeling an event of the browser and their im using m_spWebBrowser .

        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