How to get the current active document of MDI application?
-
Currently I am notifying all the open documents like below.
for(POSITION pos = pDocMgr->GetFirstDocTemplatePosition();pos;)
{
pDocTemp = pDocMgr->GetNextDocTemplate(pos);for(POSITION postemp = pDocTemp->GetFirstDocPosition();postemp;)
{
pDoc = (CMDITabsDemoDoc*)pDocTemp->GetNextDoc(postemp);
pDoc->Notify(somedata);
}}
But now I only want to notify to the active document. Which function is available to get the active document? Note : If there are 4 tabs and tab2 is open and I am having focus on some other dialog then also it should return tab2 as active tab. However if application is minimized then it should return NULL or some other indicator.
-
Currently I am notifying all the open documents like below.
for(POSITION pos = pDocMgr->GetFirstDocTemplatePosition();pos;)
{
pDocTemp = pDocMgr->GetNextDocTemplate(pos);for(POSITION postemp = pDocTemp->GetFirstDocPosition();postemp;)
{
pDoc = (CMDITabsDemoDoc*)pDocTemp->GetNextDoc(postemp);
pDoc->Notify(somedata);
}}
But now I only want to notify to the active document. Which function is available to get the active document? Note : If there are 4 tabs and tab2 is open and I am having focus on some other dialog then also it should return tab2 as active tab. However if application is minimized then it should return NULL or some other indicator.
You can use
CFrameWnd::GetActiveDocument
. This returns the document attached to the currently active view.«_Superman_» _I love work. It gives me something to do between weekends.