按TAB键时,在MFC对话框调用的WPF用户控件中承载的WebBrowser挂起. [英] WebBrowser hosted in a WPF user control called from MFC dialog hangs when pressing the TAB key.

查看:81
本文介绍了按TAB键时,在MFC对话框调用的WPF用户控件中承载的WebBrowser挂起.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同事们,

我正在处理一个奇怪的场景,我将在这里尝试解释.我不知道我还能做些什么来找到解决方案,所以我在这里发布的期望是有人可以帮助我.

我使用WPF创建了一个用户控件. VS2008在.NET 3.5中的C#.该控件放置在dll中.该控件具有工具栏,右侧的树形视图和左侧的浏览器.在XAML代码内部,我要插入WindowsFormsHost中托管的WebBrowser控件.如果我也从使用WPF的Container中使用此控件,则一切正常.

当我尝试从MFC应用程序中调用提到的控件时,就会出现问题.我创建了一个无模式对话框,并调用了WPF控件.第一个问题是WM_CHARS消息被某人吃光了,并且我在WPF控件中没有收到任何击键.希望我找到了这个有用的链接,可以帮助我解决问题:

http://devonethatdevelops.wordpress.com/2007/10/30/wpf-win32-interop-with-hwndsource/

但是主要的问题是,当我将焦点放在Web浏览器中并按TAB键时,无模式对话框和应用程序都会挂起.我唯一能做的就是去任务管理器并结束该过程.我一直在寻找类似的问题,但一无所获.我试图在包含对话框和用户控件中的每个KeyDown事件上都设置断点,但没有任何反应. TAB密钥似乎完全由不知道是谁弄肿了.

我已经从WPF容器执行了WPF控件,并且KeyDown事件到达了我按下的每个键的控件,但是当我从MFC对话框调用它时,程序不会在断点处停止. /p>

我唯一知道的是在Web浏览器控件中按TAB键会冻结应用程序.

请,您对可能发生的事情有任何了解吗?有任何线索吗?

好吧,无论如何,感谢您耐心阅读.

奥斯卡·奥尔特加(Oscar Ortega)

解决方案

请更详细地描述如何在MFC应用程序中托管UserControl:使用的窗口类型,函数调用,任何自定义消息过滤器.您如何运行消息循环?

在本机应用程序中托管它时,必须满足WPF的互操作要求:http://devonethatdevelops.wordpress.com/2007/10/30/wpf-win32-interop-with-hwndsource/

 

But the main problem is that when I put the focus in the web browser and press the TAB key, both the modeless dialog and the application hang. The only thing I can do is go to the task manager and end the process. I've been searching similar problems but found nothing. I've tried to put breakpoints on every KeyDown event both in the containing dialog and in the user control but nothing happens. It seems as though the TAB key absolutely swollen by don't-know-who.

 

I've executed the WPF control from a WPF container and the KeyDown events reach my control on every key I press, but when I call it from the MFC dialog the program don't stop in the breakpoints.

 

The only thing I know is that pressing the TAB key inside the web browser control frozens the application.

 

Please, do you have any idea of what could be happening? Any clue?

 

Well, thanks anyway for having had the patience of reading this.

 

Oscar Ortega

 

解决方案

Please describe in some more detail how you are hosting the UserControl in your MFC application: types of windows used, function calls, any custom message filters. How are you running the message loop?

You have to satisfy WPF's interop requirements when hosting it in a native application: http://msdn2.microsoft.com/en-us/library/aa348549.aspx

If your problem persists and you can share a stripped down application that demonstrates it, we could take a look.

Given the layering of technologies, there may be some weirdness happening. I suspect WinForms and its message filtering. Just as an experiment, replace the WebBrowser control with a WPF Frame (it can be navigated to HTML).


这篇关于按TAB键时,在MFC对话框调用的WPF用户控件中承载的WebBrowser挂起.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆