使用WPF webbrowser

时间:2017-12-17 10:37:16

标签: webbrowser-control

我正在使用WPF webbrowser显示画布,我可以将javascript中的鼠标事件连接到DOM,鼠标滚轮事件除外。只要鼠标在web浏览器控件上,也不会从外部检测到鼠标事件。将焦点设置为DOM控件也无济于事。 我用meta http-equiv ='X-UA-Compatible'内容='IE = edge,charset = UTF-8'

模拟Edge

还有什么可以尝试的?

1 个答案:

答案 0 :(得分:0)

Found a working solution. Added Microsoft HTML from COM page to references. Added eventhandler for the webbrowser control wb and:

`private void wb1_Loaded(object sender, RoutedEventArgs e)
 {
   mshtml.HTMLDocumentEvents2_Event doc = ((mshtml.HTMLDocumentEvents2_Event)wb1.Document);
        doc.onmousewheel += (ev) => {
            dynamic d = ((dynamic)ev).wheelDelta; 
            return true;
        };  
`}

wheelDelta can now be injected to the DOM