Webbrowser repaint
-
I developing a webbrowser using CHtmlView. But this browser is not repaint properly. That is, i want to use CView::Invalidate() for browser repaint. But this function is not work. Anybody have sample code. Thanks in advance. dooly
To have the view repaint, call CHtmlView::Refresh(). CHtmlView doesn't behave like a normal MFC view because all it does is wrap the WebBrowser control.
-
I developing a webbrowser using CHtmlView. But this browser is not repaint properly. That is, i want to use CView::Invalidate() for browser repaint. But this function is not work. Anybody have sample code. Thanks in advance. dooly
You can use CHTMLView::GetHTMLDocument to get the dispatch pointer for the document. Then you can get the window for the document. If you use Spy++, you will see that this has a classname of "Internet Explorer_Server". The following code will get you the handle to the window so that you can call InvalidateRect and UpdateWindow on it. IOleWindow* pOleWindow = NULL; HWND hWnd = NULL; // pDispatch is the IDispatch pointer retrieved from GetHTMLDocument of CHTMLView. HRESULT hr = pDispatch->QueryInterface(IID_IOleWindow,(LPVOID*)&pOleWindow); if (SUCCEEDED(hr) && pOleWindow) { hr = pOleWindow->GetWindow(&hWnd); // Ouput the classname to the debugger for verification if (SUCCEEDED(hr)) { TCHAR szClassName[256]; GetClassName(hWnd, szClassName, 256); OutputDebugString(szClassName); OutputDebugString(TEXT("\n")); } pOleWindow->Release(); pOleWindow = NULL; } I hope this helps, -Erik Thompson
-
You can use CHTMLView::GetHTMLDocument to get the dispatch pointer for the document. Then you can get the window for the document. If you use Spy++, you will see that this has a classname of "Internet Explorer_Server". The following code will get you the handle to the window so that you can call InvalidateRect and UpdateWindow on it. IOleWindow* pOleWindow = NULL; HWND hWnd = NULL; // pDispatch is the IDispatch pointer retrieved from GetHTMLDocument of CHTMLView. HRESULT hr = pDispatch->QueryInterface(IID_IOleWindow,(LPVOID*)&pOleWindow); if (SUCCEEDED(hr) && pOleWindow) { hr = pOleWindow->GetWindow(&hWnd); // Ouput the classname to the debugger for verification if (SUCCEEDED(hr)) { TCHAR szClassName[256]; GetClassName(hWnd, szClassName, 256); OutputDebugString(szClassName); OutputDebugString(TEXT("\n")); } pOleWindow->Release(); pOleWindow = NULL; } I hope this helps, -Erik Thompson
-
To have the view repaint, call CHtmlView::Refresh(). CHtmlView doesn't behave like a normal MFC view because all it does is wrap the WebBrowser control.