IE9 web control not redrawing itself in CHtmlView

别来无恙 提交于 2019-12-24 09:58:57

问题


This is an old MFC application which implements some tabbed frame windows. Only one CView is shown at any time in the frame, when switching tabs the following code is used to hide the old tab content and display the new one:

oldview->EnableWindow(FALSE);
oldview->ShowWindow(SW_HIDE);
newview->EnableWindow(TRUE);
newview->ShowWindow(SW_SHOW);
newview->SetFocus();

Now this all worked nicely for any kind of CView-s, including CHtmlView-derived ones, but stopped working when IE9 was installed on the computer (IE8 worked fine). When switching tabs from and back to a CHtmlView, the web browser control does not redraw itself and the previous tab content remains visible. When dragging e.g. a calculator window over that area, the content reappears in a ragged manner, indicating that the control just did not understand the window content was invalidated and needs to be redrawn. Adding a newview->Invalidate() call does not help, probably I should dig deeper in the CHtmlView and send some message to the web browser control directly?

TIA, Paavo


回答1:


OK, mystery solved. It appeared that clicking on the tab also activated a drag loop elsewhere in the code, and before starting the drag the following code was executed for redrawing the just activated tab:

MSG msg;  
while (::PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE))
    {
        if (!::GetMessage(&msg, NULL, WM_PAINT, WM_PAINT))
            return;
        DispatchMessage(&msg);
    }

It seems however that this code totally confused the IE9 web browser control. After deleting this code the redraw works nicely (and I have to solve the dragging behavior in some other way).



来源:https://stackoverflow.com/questions/7344413/ie9-web-control-not-redrawing-itself-in-chtmlview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!