Solved

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

Posted on 1998-11-10
4
271 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA "SendKeys" Syntax for Multiple Keystrokes 7 108
matchUp  challenge 9 110
scoreUp challenge 14 63
Making an alias 7 95
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

809 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