LRESULT Cv11View::OnHighlightRibbonListItem(WPARAM wp, LPARAM lp) { int index = (int)wp; CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*)lp; UINT id = pElem->GetID(); // button id (ID_SHAPE, ID_COLOR) if (index == -1) { shape = saveshape; color = savecolor; } else { if (ID_SHAPE == id) { shape = index; } if (ID_COLOR == id) { CMFCRibbonColorButton * button = (CMFCRibbonColorButton*)pElem; color = button->GetHighlightedColor(); } } Invalidate(); return 0; }
void CMainFrame::OnButtonEditclass( ) { if ( gbClassBrowser ) { CDialogClasses dlg; dlg.DoModal( ); } else { // TODO:instead of menu popup a window CMFCRibbonBaseElement* pButton = m_wndRibbonBar.FindByID( ID_BUTTON_EDITCLASS ); CRect pos = pButton->GetRect( ); ClientToScreen( &pos ); CMenu menu; menu.CreatePopupMenu( ); for ( UINT m = 0; m < theApp.Classes.size( ); m++ ) { CString MenuItem; MenuItem.Format( "%i - %s", m, theApp.Classes[m]->Name ); menu.AppendMenu( MF_STRING | MF_ENABLED, WM_CLASSMENU + m, MenuItem ); } menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_HORNEGANIMATION, pos.left, pos.bottom, this ); } }
void CMainFrame::UpdateStatusBarCountPane(int nID, CString strText, int nCount) { // <snippet8> // CMFCRibbonStatusBar m_wndStatusBar CMFCRibbonBaseElement* pPane = m_wndStatusBar.FindByID(nID); // </snippet8> if (pPane != NULL) { if (nCount == 0) { strText += _T(": None"); } else { CString strFormatted; strFormatted.Format(_T(": %d"), nCount); strText += strFormatted; } // <snippet9> pPane->SetDescription(_T("a pane")); // CString strText pPane->SetText(strText); pPane->SetKeys(_T("p")); pPane->SetToolTipText(_T("this is a pane")); // </snippet9> } }
void CMainFrame::OnButtonDeleteclass() { CMFCRibbonBaseElement* pButton = m_wndRibbonBar.FindByID(ID_BUTTON_DELETECLASS); CRect pos = pButton->GetRect( ); ClientToScreen( &pos ); CMenu menu; menu.CreatePopupMenu( ); for ( UINT m = 0; m < theApp.Classes.size( ); m++ ) { menu.AppendMenu( MF_STRING | MF_ENABLED, WM_DELETECLASSMENU + m, theApp.Classes[m]->Name ); } menu.TrackPopupMenu( TPM_LEFTALIGN | TPM_HORNEGANIMATION, pos.left, pos.bottom, this ); }
LRESULT CMainFrame::OnStatusUpdate(WPARAM wParam, LPARAM lParam) { CString *status = reinterpret_cast<CString *>(lParam); std::_tstring text = _T("Ready"); if (status) { text = *status; delete status; } CMFCRibbonBaseElement * elem = wParam == 0 ? m_wndStatusBar.GetElement(wParam) : m_wndStatusBar.GetExElement(wParam - 1); elem->SetText(text.c_str()); if (wParam > 0) { if (text.length()) m_wndStatusBar.RecalcLayout(); m_wndStatusBar.RedrawWindow(); } return 0; }
void CRibbonTooltipCtrl::OnShow(NMHDR* pNMHDR, LRESULT* pResult) { m_nID = 0; CPoint point; ::GetCursorPos(&point); if (m_pParentRibbon != NULL) { ASSERT_VALID(m_pParentRibbon); m_pParentRibbon->ScreenToClient(&point); CMFCRibbonBaseElement* pHit = m_pParentRibbon->HitTest(point, TRUE); if (pHit != NULL) { ASSERT_VALID(pHit); m_nID = pHit->GetID(); } } else if (m_pParentMenuBar != NULL) { ASSERT_VALID(m_pParentMenuBar); m_pParentMenuBar->ScreenToClient(&point); CMFCRibbonBaseElement* pHit = m_pParentMenuBar->HitTest(point); if (pHit != NULL) { ASSERT_VALID(pHit); m_nID = pHit->GetID(); } } CMFCToolTipCtrl::OnShow(pNMHDR, pResult); }
afx_msg LRESULT Cv11View::OnAfxWmOnHighlightRibbonListItem(WPARAM wParam, LPARAM lParam) { int index = int(wParam); CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*)lParam; UINT id = pElem->GetID(); switch (id){ case ID_SHAPE: shape = index; Invalidate(); break; case ID_COLOR: CMFCRibbonColorButton *button = (CMFCRibbonColorButton*)pElem; color = button->GetHighlightedColor(); Invalidate(); break; } if (index == -1) { shape = shape_t; color = color_t; Invalidate(); } return 0; }
LRESULT Cv11View::OnHighlightRibbonListItem(WPARAM wp, LPARAM lp) { int index = (int)wp; CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*)lp; UINT id = pElem->GetID(); // button id (ID_SHAPE, ID_COLOR) if (index >= 0){ if (id == ID_SHAPE){ shape = index; Invalidate(); } if (id == ID_COLOR){ CMFCRibbonColorButton* pColor = (CMFCRibbonColorButton*)pElem; color = pColor->GetHighlightedColor(); Invalidate(); } } else { shape = shape1; color = color1; Invalidate(); } return 0; }
LRESULT CMainFrame::OnHighlightRibbonListItem(WPARAM wp, LPARAM lp) { int nIndex = (int) wp; CMFCRibbonBaseElement* pElem = (CMFCRibbonBaseElement*) lp; ASSERT_VALID(pElem); const UINT uiCommand = pElem->GetID(); CFrameWnd* pFrame = GetActiveFrame(); if (pFrame == NULL) { return 0; } CDrawDoc* pDoc = (CDrawDoc*)pFrame->GetActiveDocument(); if (pDoc == NULL) { return 0; } ASSERT_VALID(pDoc); CDrawView* pView = DYNAMIC_DOWNCAST(CDrawView, pFrame->GetActiveView()); if (pView == NULL) { return 0; } if (uiCommand != ID_VIEW_PAPERCOLOR) { if (nIndex != -1) { pView->StorePreviewState(); } else { pView->RestorePreviewState(); } } switch (uiCommand) { case ID_VIEW_PAPERCOLOR: case ID_OBJECT_FILLCOLOR: case ID_OBJECT_LINECOLOR: { COLORREF color = ((CMFCRibbonColorButton*) pElem)->GetHighlightedColor(); if (uiCommand == ID_VIEW_PAPERCOLOR) { pDoc->SetPreviewColor(color); } else if (nIndex != -1) { if (uiCommand == ID_OBJECT_FILLCOLOR) { pView->PreviewFillColor(color); } else { pView->PreviewLineColor(color); } } CMFCPopupMenu::UpdateAllShadows(); } break; case ID_OBJECT_LINEWEIGHT: if (nIndex != -1) { pView->PreviewLineWeight(nIndex + 1); CMFCPopupMenu::UpdateAllShadows(); } break; case ID_OBJECT_STYLES: if (nIndex != -1) { pView->PreviewStyle(c_Styles[nIndex].clrFill, c_Styles[nIndex].clrLine); CMFCPopupMenu::UpdateAllShadows(); } break; } return 0; }