i'm displaying a openlayers map inside a winform web browser, since i'm getting focused on map element(with a click on the map), i have not getting mouse wheel events any more,even not document mousewheel event, to start getting the events again i need to click on some other element rather than a map element. when the app is running outside of the web browser(in IE,chrome,Firefox) everything working fine. Has anyone seen a similar problem?

  • Yes, countless times, for countless reasons. Most likely you have a Javascript error somewhere. Without a minimum working example, it is likely to be rather hard to diagnose. – John Powell Mar 19 '15 at 11:50
  • As i said, everything working fine in a browser, the problem is winform web browser. i have no errors. – Ilia Aronov Mar 19 '15 at 12:12

This is because losing focus on the map inside winform. You can use yourBrowserControl.Document.Focus() to re-focus on the map after any of your c# actions and you will get your mouse wheel control back.

In my case, I used splitContainer to split the screen and I used the following code which works out great. Every time when I click on the map, it will gain the focus back to the map, then the mouse wheel will work.

// add event hander
this.splitContainerMain.Panel2.Enter += new System.EventHandler(this.splitContainerMain_Panel2_Enter);

// handler method
private void splitContainerMain_Panel2_Enter(object sender, EventArgs e){
    if (webBrowserMap.Document != null)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.