IE9 web control not redrawing itself in CHtmlView

2019-07-28 12:12发布

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条回答
闹够了就滚
2楼-- · 2019-07-28 12:32

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).

查看更多
登录 后发表回答