Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set focus to main form after going to url/file in webbrowser control

Status
Not open for further replies.

flbos

Programmer
Sep 15, 2005
41
NL
Hi All,

I use the Microsoft webbrowser component (com component) to preview .pdf .doc .xls and .txt docs. Users can select a document with a combobox and then I let the webbrowser navigate to the chosen document with the following code:

AxWebBrowser.Navigate2("selectecdocument.doc")

This works fine but after that the document has been loaded in the webbrowser control, the cursor ends up in the document that has been loaded. For example when loading a word doc the cursor ends up within the word document and when the user types something he/she is changing the document.

I want to prevent users from editing the document and therefore I need to move the cursor out of the word document after the document has been loaded. However, things like this (after the navigate2 command):

me.focus
or
nameofanycontrolontheform.focus

don't work. I guess this is because the focus is set to a different application (in my example ms word) after the document has been loaded. Would there be any way to place the cursor back anywhere on my form (outside the webbrowser control) and thus switch back to my own application??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top