Navigate2 方法返回 S_OK 后卡在 READYSTATE_LOADING 的 READYSTATE 处

发布于 2024-08-31 12:33:27 字数 711 浏览 4 评论 0原文

我正在开发一个 MFC 文档视图架构应用程序,该应用程序具有多个文档和视图以及选项卡式窗口界面。

我的任务是在按下其他选项卡之一中的“确定”按钮时自动切换到另一个选项卡。单击另一个选项卡时,它使用 IWebBrowser2 上的 C++ 包装器导航到特定网页。

当通过单击选项卡手动完成此操作时,一切都很好,并且视图中的网页加载成功。

在我第一次尝试执行此操作时,选项卡成功切换以响应调用,

 AfxGetMainWnd()->SendMessageToDescendants(SOME_MESSAGE, ...);

但是通过在错误的位置发送此窗口消息,一旦控制返回,应用程序就会崩溃,因为事件链导致了(无模式)对话框(*) 发送的消息,不再存在。

然后我找到了拨打电话的正确位置,但现在当激活另一个选项卡时,它不再按应有的方式显示网页。

为了调试这个问题,我添加了代码来检查 READYSTATE 是否工作的情况和不工作的情况。当页面加载失败时(尽管调用 Navigate2 返回 S_OK),READYSTATE 只会停留在 READYSTATE_LOADING 状态。

不幸的是,现在与部分工作时相比,我进行了许多编辑。

我已将 TRACE 语句添加到最明显的事件,例如 OnSetFocus、CView::OnActivateView,但所有跟踪都以相同的顺序出现,尽管行为不同

* 托管在视图中

I am working on a MFC Document View architecture application which has multiple documents and views and a tabbed window interface.

I have been tasked with making an automatic switch to another tab on the press of the OK button in one of the other tabs. When the other tab is clicked on it uses a C++ wrapper over IWebBrowser2 to navigate to a specific web page.

When this is done manually by clicking on the tab everything is fine and the webpage within the view loads successfully.

In my first attempt at doing this the tab successfully switched in response to a call to

 AfxGetMainWnd()->SendMessageToDescendants(SOME_MESSAGE, ...);

however by sending this windows message at the wrong point the application would crash once control returned because the chain of events caused the (modeless) dialog (*) that
sent the message, to no longer exist.

I then found the correct place to make the call, but now when the other tab is activated, it no longer displays the webpage as it should.

To debug this problem I added code to check the READYSTATE in both the situation where it works and the situation where it does not. When the page fails to load (despite the call to Navigate2 returning S_OK), the READYSTATE just stays at READYSTATE_LOADING.

Unfortunately now I am to many edits away from when I had it partially working.

I have added TRACE statements to the most obvious events such as OnSetFocus, CView::OnActivateView but all traces come out in the same order despite the behaviour being different

* hosted in the view

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文