Solved

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

Posted on 1998-11-10
4
248 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
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
fstab earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now