1. 程式人生 > >MFC CMainFrame 獲得所有子窗體(一)

MFC CMainFrame 獲得所有子窗體(一)

CObList lstFrames;

CDocManager *pDocManager = AfxGetApp()-> m_pDocManager;

POSITION pos = pDocManager-> GetFirstDocTemplatePosition();
while(pos)
{
        CDocTemplate*   pTemplate   =   (CDocTemplate*)pDocManager-> GetNextDocTemplate(pos);
        {
POSITION   pos   =   pTemplate-> GetFirstDocPosition();

while   (pos)
{
CDocument*   pDoc   =   pTemplate-> GetNextDoc(pos);
{
POSITION   pos   =   pDoc-> GetFirstViewPosition();
while(pos)
{
CView   *pView   =   pDoc-> GetNextView(pos);
CFrameWnd   *pFrame   =   pView-> GetParentFrame();
if(lstFrames.Find(pFrame)   ==   NULL)
{
lstFrames.AddTail(pFrame);

}
}
}
}
        }