简体   繁体   English

C ++ / MFC-防止吊子(ActiveX)控件冻结整个UI?

[英]C++/MFC - Preventing a hanging child (ActiveX) control from freezing the whole UI?

I'm currently playing around with Microsofts WebBrowser ActiveX control and I noticed that I can freeze my whole program by loading a web page that crashes the embedded IE. 我目前正在使用Microsoft的WebBrowser ActiveX控件,我注意到可以通过加载使嵌入式IE崩溃的网页来冻结整个程序。 So I wondered if there's any way to prevent the whole programm from freezing? 所以我想知道是否有什么方法可以防止整个程序冻结?

I already tried: - To Create a new CWinThread creating/handling the Control --> Same result - To Create a new Dialog from this Thread creating/handling the Control --> Same result 我已经尝试过:-创建一个新的CWinThread创建/处理控件->相同的结果-从此线程创建一个新对话框创建/处理控件->相同的结果

The Problem seems to be deep in the message system, but I'm not sure. 问题似乎在消息系统中很深,但是我不确定。

Can anyone tell me if it is is even possible to prevent the whole UI/Dialog from freezing and what causes this problem? 谁能告诉我是否甚至有可能防止整个UI /对话框冻结,并且是什么导致了此问题?

(I already searched the web but I couldn't find any real solution) (我已经在网上搜索过,但是找不到任何真正的解决方案)

Thanx, Gary Thanx,加里

PS: The only way that currently works for me is to create a new child process loading/handling the control. PS:目前对我来说唯一有效的方法是创建一个新的子进程来加载/处理控件。 I can modifiy it so that it looks like a child window of my main dialog but this takes the ability from me to access the control directly from my main dialog code. 我可以对其进行修改,使其看起来像主对话框的子窗口,但这使我能够直接从主对话框代码访问控件。

EDIT: 编辑:

Okay I found a solution that satisfies me. 好吧,我找到了一个令我满意的解决方案。 I'm creating a placeholder window in the main application and start a new child process containing the actual control. 我正在主应用程序中创建一个占位符窗口,并启动一个包含实际控件的新子进程。 I delegate all window move/size/etc. 我委托所有窗口移动/大小/等。 messages to the child process so that it can reposition/react. 消息发送给子进程,以便它可以重新定位/反应。 It was important not to create the new process as a WS_CHILD object from my main application because that way it would still freeze it. 重要的是不要从我的主应用程序中将新流程创建为WS_CHILD对象,因为那样仍会冻结它。 I'm sharing information through a memory map with the process and comunicate using custom user messages. 我正在通过内存映射与进程共享信息,并使用自定义用户消息进行通信。 I Hoped it would be easier... 我希望这会更容易...

This is a very complex area. 这是一个非常复杂的区域。 Preventing problems in one UI object causing problems in directly-releated parent UI object is something that has consumed a lot of time for the browser folks, who've attempted to ensure that one tab cannot crash another. 防止一个UI对象出现问题导致直接释放的父UI对象出现问题对于浏览器人员来说已经花费了很多时间,他们试图确保一个选项卡不会崩溃。 I think it's fair to say that this is rocket science, and too large a topic to describe here. 我认为可以说这是火箭科学,这是一个太大的话题,无法在此描述。

You've picked a good starting point (separate the frame into a new process). 您已经选择了一个很好的起点(将框架分为一个新的过程)。 Something else you will want to learn about is thread input queues and AttachThreadInput (http://msdn.microsoft.com/en-us/library/ms681956(VS.85).aspx). 您还需要了解的其他事情是线程输入队列和AttachThreadInput(http://msdn.microsoft.com/zh-cn/library/ms681956(VS.85).aspx)。 Raymond has some content on this too; 雷蒙德对此也有一些了解; including part of PDC talk http://blogs.msdn.com/b/oldnewthing/archive/2008/08/01/8795860.aspx . 包括PDC演讲的一部分http://blogs.msdn.com/b/oldnewthing/archive/2008/08/01/8795860.aspx

Extra advice: An alternative here might be to simply disallow loading AX controls in your browser control if you don't need them. 额外建议:这里的一种替代方法可能是,如果不需要,则禁止在浏览器控件中加载AX控件。 And if yo do need them and are building a very general browsing replacement, you should anticipate lots of work to replicate the stability you'll find in the main browsers. 而且,如果确实需要它们并且正在构建非常通用的浏览器替代品,那么您应该期望进行大量工作来复制在主浏览器中所能找到的稳定性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM