Article ID: 195033
Article Last Modified on 11/21/2006
BOOL COleFrameHook::OnDocActivate(BOOL bActive)
{
...
COleFrameHook* pNotifyHook = m_pActiveItem->m_pInPlaceFrame;
...
// Unhook top-level frame if not needed.
if (pNotifyHook != this)
{
// Shouldn't be removing some other hook.
ASSERT(pNotifyHook->m_pFrameWnd->m_pNotifyHook == pNotifyHook);
pNotifyHook->m_pFrameWnd->m_pNotifyHook = NULL;
}
...
}
// CMyView is a CView-derived class.
void CMyView::OnInitialUpdate()
{
CView::OnInitialUpdate();
m_pSelection = NULL; // Initialize selection.
}
// CChildFrame is a CMDIChildWnd-derived class.
CChildFrame::CChildFrame()
{
// TODO: add member initialization code here.
m_bFirstTime = TRUE; // Add data member m_bFirstTime of BOOL type.
}
// Use ClassWizard to add this WM_MDIACTIVATE message handler to
// the CMDIChildWnd-derived class.
void CChildFrame::OnMDIActivate(
BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
if (m_bFirstTime && bActivate)
{
CView* pView = GetActiveView();
ASSERT_VALID(pView);
//Active documents should always be activated.
COleDocument* pDoc = (COleDocument*) pView->GetDocument();;
if (pDoc != NULL)
{
// Activate the first one...
POSITION posItem = pDoc->GetStartPosition();
if (posItem != NULL)
{
CDocItem* pItem = pDoc->GetNextItem(posItem);
// only if it's an Active document.
COleDocObjectItem *pDocObjectItem =
DYNAMIC_DOWNCAST(COleDocObjectItem, pItem);
if (pDocObjectItem != NULL)
{
pDocObjectItem->DoVerb(OLEIVERB_SHOW, pView);
}
}
}
m_bFirstTime = FALSE;
}
CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
}
Additional query words: docobject Word Excel PowerPoint
Keywords: kbactivedocs kbbug kbcontainer KB195033