Click here to Skip to main content
12,951,983 members (63,174 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 28 Jun 2000

Find in CWebBrowser Control

, 10 Aug 2000
Rate this:
Please Sign up or sign in to vote.
How to display the "Find" window in a CWebBrowser control.


An application that I had been assigned to write, required me to display reports that could possibly be over 10,000 lines in a CWebBrowser control. These 10,000 lines sometimes took a matter of hours to produce, so it was decided that it would be nice to display the report as it was generated, line by line. Being reasonably new to COM, I posted the question "How?" in the CodeProject message area. Along came Colin Davies, with a bit a code. In a 10,000 line report, it can take the user a lllloooonnnngggg time to find what they are looking for!

IE5 has the Edit - Find (on this page)... CTRL+F option that searches the current page. So I investigated implementing this in my CWebBrowser control, and found it was not as easy as it had first sounded to a COM newbie. Anyway after searching some rather confusing MSDN articles I hacked some code to produce this code slice, which can also be modified to display the View Source and Options windows as well.

Source listing

#include <initguid.h>
            0xBD5B,0x11cf,0xBA, 0x4E,0x00,

DWORD nCmdID = 1; 


//m_htmlview is the member variable 
//for the CWebBrowser2 control.

lpDispatch = m_htmlview.GetDocument();

// Get an IDispatch pointer for the 
// IOleCommandTarget interface.


// Invoke the given command id for 
// the WebBrowser control
        &CGID_IWebBrowser, nCmdID, 0,
        NULL, NULL);

// Release the command target


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Instructor / Trainer
United Kingdom United Kingdom
Is was a hardware engineer that wrote the odd bit of MFC software. A redundancy and career change later, I now teach 11-19 year olds Mechanical Engineering and Computer Science.
Group type: Organisation (No members)

You may also be interested in...


Comments and Discussions

GeneralHandle to this dialog Pin
will07070721-Sep-07 9:31
memberwill07070721-Sep-07 9:31 
GeneralApplet in WebBrowser Pin
colin-12312-Sep-06 23:49
membercolin-12312-Sep-06 23:49 
QuestionHow Can this be used IN C# Pin
jdnx21-Apr-06 22:16
memberjdnx21-Apr-06 22:16 
General10x Pin
cata_100026-Sep-05 8:15
membercata_100026-Sep-05 8:15 
GeneralSave as &quot;Web Page, complete&quot; Pin
leuven2-Jun-04 22:19
memberleuven2-Jun-04 22:19 
GeneralRe: Save as &quot;Web Page, complete&quot; Pin
Ickis15-Jun-04 1:42
memberIckis15-Jun-04 1:42 
GeneralRe: Save as &quot;Web Page, complete&quot; Pin
drake2830-Dec-04 5:02
memberdrake2830-Dec-04 5:02 
Questionhow to navigate to HTML page from resouces Pin
george ivanov18-Dec-03 2:54
membergeorge ivanov18-Dec-03 2:54 
AnswerRe: how to navigate to HTML page from resouces Pin
Jeremy Davis18-Dec-03 3:47
memberJeremy Davis18-Dec-03 3:47 
QuestionCan I use it with CHtmlView Pin
Naren7-Sep-02 2:39
memberNaren7-Sep-02 2:39 
AnswerRe: Can I use it with CHtmlView Pin
mmori14-Mar-04 11:23
membermmori14-Mar-04 11:23 
QuestionHow can I get the HTML text from Webbrowser Control ? Pin
Hiroshi2-Oct-01 2:23
memberHiroshi2-Oct-01 2:23 
QuestionHow can I get the HTML text from Webbrowser Control ? Pin
Hiroshi2-Oct-01 2:22
memberHiroshi2-Oct-01 2:22 
AnswerRe: How can I get the HTML text from Webbrowser Control ? Pin
pawlb24-Oct-02 11:50
susspawlb24-Oct-02 11:50 
GeneralThe arguments to the find method Pin
Tim Ford4-Jun-01 0:42
memberTim Ford4-Jun-01 0:42 
GeneralRe: The arguments to the find method Pin
Jeremy Davis25-Jul-01 23:27
memberJeremy Davis25-Jul-01 23:27 
QuestionGet explore device context..? Pin
donghun lee22-Mar-01 18:53
memberdonghun lee22-Mar-01 18:53 
GeneralRight button -->> IE pop-up menu Pin
Anonymous25-Feb-01 7:16
memberAnonymous25-Feb-01 7:16 
GeneralRe: Right button -->> IE pop-up menu Pin
Jeremy Davis16-Mar-01 3:00
memberJeremy Davis16-Mar-01 3:00 
GeneralRe: Right button -->> IE pop-up menu Pin
Biri5-Jun-01 3:01
memberBiri5-Jun-01 3:01 
GeneralRe: Right button -->> IE pop-up menu Pin
KaЯl3-Jan-03 3:09
memberKaЯl3-Jan-03 3:09 
GeneralRe: Right button -->> IE pop-up menu Pin
Jeremy Davis22-Aug-01 22:49
memberJeremy Davis22-Aug-01 22:49 
Questionhow i can use it? Pin
jaims15-Aug-00 16:12
sussjaims15-Aug-00 16:12 
AnswerRe: how i can use it? Pin
Jeremy Davis21-Aug-00 23:44
sussJeremy Davis21-Aug-00 23:44 
GeneralSave As Pin
Brian Hart14-Aug-00 19:17
sussBrian Hart14-Aug-00 19:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 11 Aug 2000
Article Copyright 2000 by jerry0davis
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid