-1

I want to get the find dialog (Which opens with a control + F) as an object, for to know if it's active.

How I do it?

I went through all the parameters of the web browser control and found nothing.

Tolga Evcimen
  • 7,112
  • 11
  • 58
  • 91
  • I've never found a way to pop it up, but, if I remember correctly, `+F` works. I shipped a quickie internal app with instructions that said "if you want to find something on the page, use `+F`. – Flydog57 Jan 28 '19 at 18:22
  • What are you trying to acheive ? – Bestter Jan 28 '19 at 18:25
  • I want to hide the window when I walk out of the main window or out of this window, and when he goes to the find it seems to get out of everything. – Avraham Ben Arosh Jan 28 '19 at 18:28

1 Answers1

0

Neither the WebBrowser control, nor the native IWebBrowser2 interface expose the find dialog. The only interaction is launching the dialog by calling an OLE command:

SHDocVw.WebBrowser webBrowserInstance = webBrowser1.ActiveXInstance as SHDocVw.WebBrowser;
webBrowserInstance.ExecWB(
                    SHDocVw.OLECMDID.OLECMDID_FIND,
                    SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT,
                    null, null);

This works well, but neither can you pass any variables, nor do you get any back. The find dialog unfortunately isn't a child window, and it doesn't have any identifying classes or attributes. Basically you'd need to inspect all top-level windows belonging to your process, and find out if one of them is the dialog in question. Then you can send a WM_CLOSE to the window, or call CloseWindow, or somemthing similar.

There is a good collection of functions to search for (top-level) windows belonging to a process here: How to enumerate all windows belonging to a particular process using .NET?

Alexander Gräf
  • 511
  • 1
  • 3
  • 10