Cannot find WebBrowser.Find

R

rossum

I am using Visual C# Express Beta, though I suspect that my question
has more to do with .NET than with C# specifically. I have written a
form with a Web Browser in it. At the top I have a button bar. What
I want to do is to have a [Find] button which searches for
user-entered text in the HTML document in the Web Browser.

When I run my form I can type Ctrl-F and up comes a standard Find
dialogue box which does exactly what I want - the dialogue is
presumably built into the Web Browser as I certainly didn't put it
there. My problem is that I cannot find a way to trigger this Find
dialogue programatically so I can hook it into my [Find]. I have
looked through all the WebBrowser members and also through the
WebBrowser.Document members - no joy. Neither can I find a KeyPress
event attached to the WebBrowser so I could generate an internal
Ctrl-F to set things off.

If I have to I can code my own Find dialogue, but I would rather not
do this given that there is obviously one already built into the Web
Browser.

Does anyone have any thoughts as to ways to fire up the Web Browser's
Find dialogue programatically?

Thanks

rossum
 
C

Carl Daniel [VC++ MVP]

rossum said:
I am using Visual C# Express Beta, though I suspect that my question
has more to do with .NET than with C# specifically.

You should post to microsoft.public.dotnet.languages.csharp and/or
microsoft.private.whidbey.csharp.language. This group (.vc.language) is a
C++ group.

-cd
 
T

Tim Anderson

Does anyone have any thoughts as to ways to fire up the Web Browser's
Find dialogue programatically?

In the HtmlEditor (http://www.itwriting.com/htmleditor/index.php) I do this
by casting the HTMLDocument to IOleCommandTarget and then calling exec with
IDM_FIND for the argument. This should work for the WebBrowser control too;
you could take a look at the code. Maybe there's an easier way, I'm not
sure.

Tim
How much memory does my .NET application use?
http://www.itwriting.com/dotnetmem.php
 
R

rossum

[snip question]
Does anyone have any thoughts as to ways to fire up the Web Browser's
Find dialogue programatically?

Thanks

rossum

Thanks to Alexander Shirsov on
microsoft.public.dotnet.languages.csharp I now have a solution:

webBrowser.Focus();
SendKeys.Send("^f");

That is in C#. I presume that the C++ solution will be similar to:

webBrowser->Focus();
SendKeys->Send("^f");

(Warning: C++ code not tested.)

rossum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top