void CBCGPRibbonBackstagePagePrint::OnPreviewPrint() { if (!PreparePrintInfo ()) { return; } CBCGPRibbonBackstageView* pWnd = GetBackStageView (); if (pWnd != NULL) { pWnd->PostMessage (WM_CLOSE); } }
//*********************************************************************************************** void CBCGPRecentFilesListBox::OnChooseRecentFile(UINT uiCmd) { CFrameWnd* pParentFrame = BCGCBProGetTopLevelFrame (this); if (pParentFrame != NULL) { pParentFrame->PostMessage(WM_COMMAND, uiCmd); } CWnd* pParentDlg = GetParent(); if (pParentDlg != NULL) { CBCGPRibbonBackstageView* pBackstageView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pParentDlg->GetParent()); if (pBackstageView != NULL) { pBackstageView->SendMessage(WM_CLOSE); } } }
//*********************************************************************************************** void CBCGPRecentFilesListBox::OnChoosePinnedFile(LPCTSTR lpszFile) { ASSERT(lpszFile != NULL); CWnd* pParentDlg = GetParent(); if (pParentDlg != NULL) { CBCGPRibbonBackstageView* pBackstageView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pParentDlg->GetParent()); if (pBackstageView != NULL) { pBackstageView->SendMessage(WM_CLOSE); } } if (AfxGetApp() == NULL) { ASSERT(FALSE); return; } AfxGetApp()->OpenDocumentFile(lpszFile); }
//*********************************************************************************************** void CBCGPRecentFilesListBox::OnChooseRecentFolder(LPCTSTR lpszFolder) { ASSERT(lpszFolder != NULL); CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, NULL, BCGCBProGetTopLevelFrame(this)); CWnd* pParentDlg = GetParent(); if (pParentDlg != NULL) { CBCGPRibbonBackstageView* pBackstageView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pParentDlg->GetParent()); if (pBackstageView != NULL) { pBackstageView->SendMessage(WM_CLOSE); } } if (AfxGetApp() == NULL) { ASSERT(FALSE); return; } CString title; VERIFY(title.LoadString(AFX_IDS_OPENFILE)); CString strFilter; CString strDefault; CDocManager* pDocManager = AfxGetApp()->m_pDocManager; if (pDocManager != NULL) { BOOL bFirst = TRUE; for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;) { CDocTemplate* pTemplate = pDocManager->GetNextDocTemplate (pos); ASSERT_VALID (pTemplate); _BCGPAppendFilterSuffix(strFilter, dlgFile.m_ofn, pTemplate, bFirst ? &strDefault : NULL); bFirst = FALSE; } } CString fileName; // append the "*.*" all files filter CString allFilter; VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.*"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); dlgFile.m_ofn.lpstrInitialDir = lpszFolder; if (dlgFile.DoModal() == IDOK) { AfxGetApp()->OpenDocumentFile(fileName); } fileName.ReleaseBuffer(); }
//************************************************************************************** BOOL CBCGPDlgImpl::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_SYSKEYDOWN: case WM_CONTEXTMENU: if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd) && pMsg->wParam == VK_MENU) { CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE); return TRUE; } break; case WM_SYSKEYUP: if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd)) { return TRUE; // To prevent system menu opening } break; case WM_KEYDOWN: //----------------------------------------- // Pass keyboard action to the active menu: //----------------------------------------- if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd)) { CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_KEYDOWN, (int) pMsg->wParam); return TRUE; } #ifndef BCGP_EXCLUDE_RIBBON #ifndef _BCGSUITE_ if (m_bBackstageMode && (pMsg->wParam == VK_HOME || pMsg->wParam == VK_ESCAPE)) { for (CWnd* pWndParent = m_Dlg.GetParent(); pWndParent != NULL; pWndParent = pWndParent->GetParent()) { CBCGPRibbonBackstageView* pView = DYNAMIC_DOWNCAST(CBCGPRibbonBackstageView, pWndParent); if (pView != NULL) { if (pMsg->wParam == VK_HOME) { #define MAX_CLASS_NAME 255 #define EDIT_CLASS _T("Edit") TCHAR lpszClassName [MAX_CLASS_NAME + 1]; if (CWnd::GetFocus()->GetSafeHwnd() != NULL) { ::GetClassName (CWnd::GetFocus()->GetSafeHwnd (), lpszClassName, MAX_CLASS_NAME); CString strClass = lpszClassName; if (strClass == EDIT_CLASS) { return FALSE; } } pView->SetFocus(); } else // Escape { pView->SendMessage(WM_CLOSE); } return TRUE; } } return TRUE; } #endif #endif break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd); if (pWnd != NULL && ::IsWindow (pMsg->hwnd)) { pWnd->ClientToScreen (&pt); } if (ProcessMouseClick (pt)) { return TRUE; } if (!::IsWindow (pMsg->hwnd)) { return TRUE; } } break; case WM_NCLBUTTONDOWN: case WM_NCLBUTTONUP: case WM_NCRBUTTONDOWN: case WM_NCRBUTTONUP: case WM_NCMBUTTONDOWN: case WM_NCMBUTTONUP: if (ProcessMouseClick (CPoint (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)))) { return TRUE; } if (pMsg->message == WM_NCRBUTTONUP && pMsg->hwnd == m_Dlg.GetSafeHwnd () && IsOwnerDrawCaption ()) { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); UINT nHit = OnNcHitTest (pt); if (nHit == HTCAPTION || nHit == HTSYSMENU) { CMenu* pMenu = m_Dlg.GetSystemMenu (FALSE); if (pMenu->GetSafeHmenu () != NULL && ::IsMenu (pMenu->GetSafeHmenu ())) { UINT uiRes = ::TrackPopupMenu (pMenu->GetSafeHmenu(), TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_Dlg.GetSafeHwnd (), NULL); if (uiRes != 0) { m_Dlg.SendMessage (WM_SYSCOMMAND, uiRes); return TRUE; } } } } break; case WM_MOUSEWHEEL: if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd) && CBCGPPopupMenu::GetActiveMenu()->IsScrollable ()) { CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_MOUSEWHEEL, pMsg->wParam, pMsg->lParam); } #ifndef BCGP_EXCLUDE_RIBBON #ifndef _BCGSUITE_ else { CPoint ptCursor; ::GetCursorPos (&ptCursor); CWnd* pWnd = CWnd::WindowFromPoint(ptCursor); CBCGPRibbonGalleryCtrl* pGalleryCtrl = DYNAMIC_DOWNCAST(CBCGPRibbonGalleryCtrl, pWnd); if (pGalleryCtrl != NULL) { pGalleryCtrl->SendMessage (WM_MOUSEWHEEL, pMsg->wParam, pMsg->lParam); return TRUE; } } #endif #endif break; case WM_MOUSEMOVE: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd); if (pWnd != NULL) { pWnd->ClientToScreen (&pt); } if (ProcessMouseMove (pt)) { return TRUE; } } } return FALSE; }