Пример #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);
}
Пример #3
0
void CGuiMDITabbed::UpdateWindows()
{
	
	/* Modified by SunZhenyu
	SetTimer(1,200,NULL);
	*/
	KillTimer(1);

	CWnd* pWnd=CWnd::FromHandle(::GetTopWindow(GetParentFrame()->GetSafeHwnd()));	
	char ClassName[32];
	
	while (pWnd != NULL)
	{
		::GetClassName(pWnd->GetSafeHwnd(),ClassName,32);
		CString szClassName=ClassName;
		if(szClassName=="MDIClient")
			break;
		pWnd=pWnd->GetNextWindow();
	}
	ASSERT(::IsWindow(pWnd->GetSafeHwnd()));
	//primero adicionar los nuevos
	
	
	CWnd* pChild= CWnd::FromHandle(::GetTopWindow(pWnd->GetSafeHwnd()));	
	while(pChild != NULL)
	{
		CString m_Caption;
		pChild->GetWindowText(m_Caption);
		if (!m_Caption.IsEmpty()) 
		{
			if (!FindItem(pChild->GetSafeHwnd()))
				Addtab(pChild,m_Caption,-1);
			else
				UpdateCaption(pChild,m_Caption);
		}
		
		pChild= CWnd::FromHandle(::GetNextWindow(pChild->GetSafeHwnd(), GW_HWNDNEXT));
		
	}
	
	/* Modified by SunZhenyu */
	// get active child frame, modified 2003/6/19
	CMDIFrameWnd* pFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, GetParentFrame());
	CMDIChildWnd* pActiveChild = NULL;
	if( pFrame )
		pActiveChild	=	pFrame->MDIGetActive();
	// get active child frame, modified 2003/6/19

	
	//---eliminar las ventanas borradas
	int nNumtabs=GetCount();
	for (int i=0; i< nNumtabs; i++)
	{
			CWnd* pWnd=GetNumWnd(i);
			if (!::IsWindow(HWND(pWnd->GetSafeHwnd())))
			{
				DeleteTab(i);
				UpdateWindow();
				break;
			}
			/* Modified by SunZhenyu */
			// set cur tab by active child frame, modified 2003/6/19
			else if( pWnd->GetSafeHwnd() == pActiveChild->GetSafeHwnd() )
			{
				SetCurtab(i);
			}
			// set cur tab by active child frame, modified 2003/6/19
	}

	SetTimer(1,200,NULL);
}