Пример #1
0
CString CXTPMDIWndTab::GetChildWndText(HWND hWnd) const
{
	// Check to see if the user has defined a label for the tab first.
	CString strTitle;
	if (m_mapTabLabels.Lookup(hWnd, strTitle))
	{
		return strTitle;
	}

	// Get a pointer to the frame window.
	CMDIChildWnd* pChildFrame = (CMDIChildWnd*)CWnd::FromHandle(hWnd);
	if (!::IsWindow(pChildFrame->GetSafeHwnd()))
	{
		return _T("");
	}

	// Get the window text for the frame and use it for the tab label.
	pChildFrame->GetWindowText(strTitle);

	// If the string is empty the document's title.
	if (strTitle.IsEmpty())
	{
		CWnd* pChildWnd = pChildFrame->GetWindow(GW_CHILD);
		while (pChildWnd)
		{
			if (pChildWnd->IsKindOf(RUNTIME_CLASS(CView)))
			{
				// Get a pointer to the view's document.
				CDocument* pDoc = ((CView*)pChildWnd)->GetDocument();
				if (pDoc == NULL)
				{
					return _T("");
				}

				// Set the return string value
				strTitle = pDoc->GetTitle();

				// Reset the frames title
				pChildFrame->SetWindowText(strTitle);

				// Return the document title.
				return strTitle;
			}
			pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
		}
	}

	// Return the MDI frame window's title.
	return strTitle;
}
Пример #2
0
void CExtMdiWindowsListDlg::_FillMDIWindowList()
{
	m_ListWindows.SetRedraw(FALSE);
	m_ListWindows.ResetContent();
	
	CMDIChildWnd* pActiveChild = (CMDIChildWnd*)m_pMDIFrameWnd->MDIGetActive();
	if (pActiveChild != NULL) 
	{
		CMDIChildWnd* pChildFrame = (CMDIChildWnd*)pActiveChild->GetWindow(GW_HWNDLAST);
		while (pChildFrame != NULL) 
		{
			HWND hChildFrame = pChildFrame->GetSafeHwnd();
			CString strWindowText;
			pChildFrame->GetWindowText( strWindowText );
			if( strWindowText.IsEmpty() )
			{
				CWnd* pMDIChildWnd = pChildFrame->GetWindow(GW_CHILD);
				while( pMDIChildWnd )
				{
					if( pMDIChildWnd->IsKindOf(RUNTIME_CLASS(CView)) ) 
					{
						CDocument* pDocument = ((CView*)pMDIChildWnd)->GetDocument();
						if (pDocument == NULL)
							strWindowText = _T("");
						strWindowText = pDocument->GetTitle();
						pChildFrame->SetWindowText( strWindowText );
					} // if( pMDIChildWnd->IsKindOf(RUNTIME_CLASS(CView)) ) 
					pMDIChildWnd = pMDIChildWnd->GetWindow(GW_HWNDNEXT);
				} // while( pMDIChildWnd )
			} // if( strWindowText.IsEmpty() )
			int iIndex = m_ListWindows.AddString(strWindowText);
			m_ListWindows.SetItemData(iIndex, (DWORD)hChildFrame);
			
			pChildFrame = (CMDIChildWnd*)pChildFrame->GetWindow(GW_HWNDPREV);
		} // while (pChildFrame != NULL) 
	} // if (pActiveChild != NULL) 

	m_ListWindows.SetRedraw(TRUE);
}