do{
if(m_pDocObjectServer==NULL) break;
CComPtr<IOleObject> pOleObject;
m_pDocObjectServer->ExternalQueryInterface(&IID_IOleObject,(LPVOID*)&pOleObject);
if(pOleObject==NULL) break;
CComPtr<IOleClientSite> pOleClientSite;
pOleObject->GetClientSite(&pOleClientSite);
if(pOleClientSite==NULL) break;
CComPtr<IOleContainer> pOleContainer;
pOleClientSite->GetContainer(&pOleContainer);
if(pOleContainer==NULL) break;
CComQIPtr<IServiceProvider> pServiceProvider(pOleContainer);
if(pServiceProvider==NULL) break;
CComQIPtr<IServiceProvider> pTopLevelServiceProvider;
pServiceProvider->QueryService(SID_STopLevelBrowser, IID_IServiceProvider, (LPVOID*)&pTopLevelServiceProvider);
if(pTopLevelServiceProvider==NULL) break;
CComPtr<IWebBrowser2> pWebBrowser2;
pTopLevelServiceProvider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2,(LPVOID*)&pWebBrowser2);
if(pWebBrowser2==NULL) break;
pServiceProvider=pWebBrowser2;
CComPtr<IOleWindow> pOleWindow;
pServiceProvider->QueryService(SID_SShellBrowser, IID_IOleWindow,(LPVOID*)&pOleWindow);
if(pOleWindow==NULL) break;
HWND hwndBrowserOrTab = NULL;
pOleWindow->GetWindow(&hwndBrowserOrTab);
if(hwndBrowserOrTab==NULL) break;
CString newTitle;
newTitle.Format("%s (%d strokes)",
m_strPathName,
m_strokeList.GetSize());
BOOL result=::SetWindowText(hwndBrowserOrTab,(LPCTSTR)newTitle);
if(result==FALSE)
{
int errorCode=GetLastError(); //no error here but looks like no way to update tab caption, which is in a DirectUIHWND window in the frame process.
}
}while(FALSE);
Jiang,Sheng ,a Microsoft Most Valuable Professional of Visual C++, became a Visual C++ programmer at 1999. He actives on several online Visual C++ forums ,blogs and newsgroups
3/04/2010
Getting out of Active Document
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment