1
votes

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
After some experimenting I was able to force the webbrowser control to repaint itself by prepending the following code: newview->ShowWindow(SW_MAXIMIZE); newview->ShowWindow(SW_RESTORE); However, this causes a visible delay and some screen flicker...Paavo
did you enable FEATURE_GPU_RENDERING for your app?Sheng Jiang 蒋晟
No, I was not aware of FEATURE_GPU_RENDERING, according to the docs it should by default be disabled for web control hosting apps. However, it seems like something to consider to be added in the future!Paavo
It appears that the SW_MAXIMISE/SW_RESTORE trick does not work on another computer. So, doesn't anybody know how to force the IE control to redraw itself? I have tried to call IWebBrowser::RedrawWindow(), setting body element style to 'none' and back to 'block' (in the C++ code) and calling IHTMLPaintSite::InvalidateRect(), all to no avail (I'm not so home with COM programming so I am not so sure my attempts were the best ones). The only things which are redrawn on the HTML page are animated gifs...Paavo
It seems SW_MAXIMISE/SW_RESTORE trick only worked because the "Animate windows when minimizing and maximizing" Windows option was turned on.Paavo

1 Answers

1
votes

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