int CMainFrame::DoCloseWnd(CExtControlBar &Box)//заданное ќкно, которое требуетс¤ закрыть { CWnd *pWnd=GetFocus(); if(pWnd) { CWnd *pParent=pWnd->GetParent(); if(pParent==&Box)//если текущее окно - заданное ќкно, то не закрываем { CMDIChildWnd* pView=MDIGetActive(); if(pView) { MDIActivate(pView); pView->SetFocus(); return 0; } } //иначе, если открыто заданное ќкно - закрываем if(Box.IsVisible()) { ShowControlBar(&Box,0,1); return 1; } } return -1; }
BOOL COutWnd::bAddString(CStringArray& omStrArray) { BOOL bReturn = TRUE; INT nTotalCount = (COMMANINT)omStrArray.GetSize(); INT nReturnAdd = 0; // vResetContent(); MDIActivate(); omStrArray.Add(" "); INT nCount; //nCount declared outside for( nCount=0; nCount<nTotalCount; nCount++) { nReturnAdd = m_omListBox.AddString(omStrArray.GetAt(nCount)); if(nReturnAdd<0) { bReturn = FALSE; } } // Set horizontal extent of the list box to max string availaable // so that user can scroll CSize sz(0,0); CString omStrText = ""; CDC* pDC = m_omListBox.GetDC(); //Check for valid dc and then set the horizontal extent if( pDC != nullptr) { TEXTMETRIC tm; pDC->GetTextMetrics(&tm); //Select the new font object to calculte the extent //because font is set for window not for CDC CFont* pOldFont = pDC->SelectObject(&m_omNewFont); INT nTotalItem = m_omListBox.GetCount(); INT nDx = 0; for (nCount = 0; nCount < nTotalItem; nCount++) { m_omListBox.GetText( nCount, omStrText ); // remove space omStrText.TrimRight(); sz = pDC->GetTextExtent(omStrText); //Add avg char width for avoiding any wrapping up sz.cx += tm.tmAveCharWidth; if (sz.cx > nDx) { nDx = sz.cx; } } //release the new font pDC->SelectObject(pOldFont); m_omListBox.ReleaseDC(pDC); // Set the horizontal extent so every character of all strings // can be scrolled to. m_omListBox.SetHorizontalExtent(nDx); } else { bReturn = FALSE; } return bReturn; }
int CMDIChildWnd::OnMouseActivate(HWND hDesktopWnd,UINT nHitTest,UINT message) { int nResult=CFrameWnd::OnMouseActivate(hDesktopWnd,nHitTest,message); if (nResult==MA_NOACTIVATE || nResult==MA_NOACTIVATEANDEAT) return nResult; if (m_pParent->MDIGetActive()!=*this) MDIActivate(); return nResult; }
void CChildFrame::ActivateFrame(int nCmdShow) { if ( EnableSaveRestore(_T("Demo MDI Frame")) ) { // if correctly restored, activate window and return MDIActivate(); return; } CResizableMDIChild::ActivateFrame(nCmdShow); }
int CMDIChildWnd::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { int nResult = CFrameWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); if (nResult == MA_NOACTIVATE || nResult == MA_NOACTIVATEANDEAT) return nResult; // frame does not want to activate // activate this window if necessary CMDIFrameWnd* pFrameWnd = GetMDIFrame(); ENSURE_VALID(pFrameWnd); CMDIChildWnd* pActive = pFrameWnd->MDIGetActive(); if (pActive != this) MDIActivate(); return nResult; }
void CMainFrame::OnNextDoc() { BOOL maximized; CMDIChildWnd* activeWnd = theApp.GetMainFrame()->MDIGetActive(&maximized); if (!activeWnd) return; // start from active document and get next one POSITION pos = theApp.m_pLuaTemplate->GetFirstDocPosition(); while (pos != NULL) { CLuaDoc* pDoc = (CLuaDoc*)theApp.m_pLuaTemplate->GetNextDoc(pos); if (pDoc->GetView()->GetParentFrame() == activeWnd) { if (m_LastCycledDoc == NULL) m_LastCycledDoc = pDoc; if (pos == NULL) { pos = theApp.m_pLuaTemplate->GetFirstDocPosition(); } pDoc = (CLuaDoc*)theApp.m_pLuaTemplate->GetNextDoc(pos); MDIActivate(pDoc->GetView()->GetParentFrame()); return; } } }
/// Document commanding us to close void CChildFrame::CloseNow() { SavePosition(); // Save settings before closing! MDIActivate(); MDIDestroy(); }