Solved

How to control IE WebBrowser Control from an ActiveX control inside it?

Posted on 1998-11-10
4
292 Views
Last Modified: 2013-11-20
 I create an ActiveX Control,and use it inside IE WebBrowser Control, my question is how to control the IE WebBrowser Control.
  I can get the IE WebBrowser Control Wnd by call the function FindWindow(), but I cann't get IUnknown Pointer to the Control.
  Can anyone help me?
  Thank you!
0
Comment
Question by:linyf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
fstab earned 50 total points
ID: 1324493
By doing a QueryInterface on your control, and if this is successful, you should be able to get to the IUnknown pointer too, by doing one more QueryInterface to IUnknown. This is because of one of the rules of COM : when you can get from here to there, you can get from there to anywhere.
0
 

Author Comment

by:linyf
ID: 1324494
Thank you!
    But how can I get the IUnknown pointer?
    I used this way to get the IE WebBrowser Control that contains my control:

    CWnd * tWnd=GetParent();
    while(tWnd)
    {
      GCHAR tClassName[255];
      strcpy(tClassName,"");
      GetClassName(tWnd->m_hWnd,tClassName,250);
      if(strcmp(tClassName,"Internet Explorer_Server")==0)
      {
      }
      tWnd=tWnd->GetParent();
    }

    How can I get an IUnknown pointer through the tWnd Object?
    Or there exists other way to do this?

0
 
LVL 1

Expert Comment

by:fstab
ID: 1324495
You cannot get the IUnknown from the window handle.

The definition of QueryInterface is as follows :

HRESULT QueryInterface(
  REFIID iid,        //Identifier of the requested interface
  void ** ppvObject  //Address of output variable that receives the
                     //interface pointer requested in iid);

Do the following steps :

1. Open your system's Windows Registry - run regedit.
2. Open HKEY_CLASSES_ROOT
3. Search for the IE WebBrowser control entry - it'll usually be in the format : Vendor.Control.Version
4. Note this name down : for eg. MS***.WebBrowser.2
5. Use the function CLSIDtoProgID which returns the CLSID of this control
6. Use the CLSID returned from this function to QueryInterface

Good luck !
fstab.
0
 

Author Comment

by:linyf
ID: 1324496
Thank you very much!

    I know how to create an IE WebBrowser Control,but what I want to do is to seek for an existing WebBrowser Control that contains my own ActiveX control (because inside my control I want to call such methods as "Navigate","GoBack" and so on.),
I know CWnd class has a method called GetControlUnknown() for getting an IUnknown pointer of an OleControl,that is why I want to get an IUnknown pointer from a CWnd object. If this way is not possible, can you tell me other ways?
    Thank you again!

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question