PDA

View Full Version : web browser control focus trouble!



someboddy
09-04-2010, 08:07 AM
I have a form with a web browser control that does a search in GoogleMaps on every SelectionChange event. The problem is it steals the focus from the worksheet when the query is done - this is a big problem for me because it forces me to use the mouse which makes my wrists suffer.

Anyways, I've found a workaround for that - on the NavigateComplete2 event of the browser control, I use Application.OnTime to call a subroutine that transfers the focus to the worksheet. The reason I use OnTime instead of transferring the focus directly is that if I transfer the focus directly it will happen before the browser steals it.

Now, since I send Now as the earliest time for the OnTime it works pretty good and I don't feel the focus back and forth transfer, but still, it's a pretty ugly workaround, since OnTime won't recognize a form's subroutine even if I use "FormName.SubroutineName" so I need to create a function on a module, and more importantly - if I want to use another form to scan the rows I need to write more code that recognize who was the previous focus holder and return it to it instead of automatically return it to the worksheet.

So, does anyone know a more elegant solution to this problem?

mikerickson
09-05-2010, 10:07 AM
"The reason I use OnTime instead of transferring the focus directly is that if I transfer the focus directly it will happen before the browser steals it."

Would adding a Wait command fix that issue?