开发者

The Webbrowser in WPF can't display page unless mouse moving on

The Webbrowser in WPF can't display page unless mouse moving on.

This bug can't reproduce in my demo project, and I don't know how to fix it. I tried:

  • call WindowsFormsHost.UpdateLayout. (Failed)
  • call WindowsFormsHost's child, a WebBrowser control. call WebBrowser.Update or WebBrowser.Refresh. (Failed)
  • call WindowsFormsHost.InvalidateVisual() (Failed)

Is there other solution?


I even simulated mouse moving on like this:


AutomationElement element = AutomationElement.FromHandle(winAdHoster.Handle);
ATGTestInput.Input.MoveToAndClick(element);

this failed a开发者_JAVA百科gain.


I have tree questions:

  • Does this happens after reboot?
  • Do you have AllowsTransparency="True" for the main window?
  • What OS do you have?


In order to simulate actual mouse events, you can use following function throgh PInvoke, its system api to simulate mouse events this will work better then AutomationElement.

SendInput


I finally fixed this bug via:

  1. moved init WebBrowser code to a method, which is the last method in Window_Loaded event.
  2. using BeginInvoke and Thread.Sleep(500) before init WebBrowsers.

We tested it on WinXp and Win7, it works well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜