Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/175513

From BetaArchive Wiki
Knowledge Base

FILE: Invoke Find, View Source, Options Dialog Boxes for WebBrowser

Article ID: 175513

Article Last Modified on 8/11/2004


  • Microsoft Internet Explorer 3.0
  • Microsoft Internet Explorer 3.01
  • Microsoft Internet Explorer 3.02
  • Microsoft Internet Explorer 4.0 128-Bit Edition
  • Microsoft Internet Explorer 4.01 Service Pack 2
  • Microsoft Internet Explorer 5.0
  • Microsoft Internet Explorer 5.5

This article was previously published under Q175513


This article illustrates how to invoke the Internet Explorer Find, Internet Options, and View Source dialog boxes from within an application that is hosting the WebBrowser control. The following file is available for download from the Microsoft Download Center:

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.


Warning This sample uses an undocumented command group GUID that is subject to change in the future. Although this sample has been tested to work correctly with Internet Explorer 3.0 and 4.0, there is no guarantee that these techniques will continue to work successfully in future versions. Please use caution when adding this code to an application.

The WBSampl example is a mini-browser application that illustrates how to create an application in Microsoft Visual C++ that uses the WebBrowser control. This example provides code to invoke the Find, Internet Options, and View Source items that are part of the WebBrowser control but are not exposed as methods.

In order to implement the items listed above, the following steps should be followed.

  1. Define the command group GUID for the WebBrowser control as follows:

  2. Define the CommandTarget ids for menu driving as follows:

          #define HTMLID_FIND 1
          #define HTMLID_VIEWSOURCE 2
          #define HTMLID_OPTIONS 3
  3. Execute a CommandTarget id as follows:

          HRESULT CMainFrame::ExecCmdTarget(DWORD nCmdID)
             LPDISPATCH lpDispatch = NULL;
             LPOLECOMMANDTARGET lpOleCommandTarget = NULL;
             lpDispatch =
             // Get an IDispatch pointer for the IOleCommandTarget interface.
             // Invoke the given command id for the WebBrowser control
                  return lpOleCommandTarget->Exec(&CGID_IWebBrowser, nCmdID, 0,
                                             NULL, NULL);

Note that m_webBrowser is an instance of the WebBrowser control and is defined in the CView-derived class for this project. Also, nCmdID is one of the IDs defined in step 2.

Additional query words: WebBrowser WBSample Find Source Options Internet Explorer IE

Keywords: kbinfo kbdownload kbwebbrowser kbfile kbsample kbfaq KB175513