void CLineComputeView::OnSliderViewzoom() { CMainFrame *pMain = (CMainFrame *)AfxGetApp()->m_pMainWnd; CMFCRibbonSlider *pSlider = DYNAMIC_DOWNCAST(CMFCRibbonSlider, pMain->m_wndRibbonBar.FindByID(ID_SLIDER_VIEWZOOM)); scale = pSlider->GetPos()/10.0f; RenderScene(); }
int CMainFrame::GetSliderPos (UINT nID) { CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> ar; CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> ar2; m_wndRibbonBar.GetElementsByID (ID_RIBBON_OBTN_5, ar); m_wndRibbonBar.GetElementsByID (ID_RIBBON_OBTN_6, ar2); ar.Append (ar2); int nPos1 = -1; int nPos2 = -1; for (int k = 0; k < 2; k++) { for (int i = 0; i < ar.GetSize (); i++) { CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST (CMFCRibbonSlider, ar[i]); if (pSlider != NULL) { if (k == 0) { if (pSlider->GetID () != nID) { nPos2 = pSlider->GetPos (); nPos1 = nPos2; break; } } else { if (pSlider->GetID () == nID) { if (pSlider->GetPos () != nPos2) { nPos1 = pSlider->GetPos (); } } } } } } return nPos1; }
// Return the factor of zooming the rectangle double CRibbonAppDoc::GetSliderFactor(void) { // Get a pointer to the ribbon bar CMFCRibbonBar* pRibbon = ((CMDIFrameWndEx*) AfxGetMainWnd())->GetRibbonBar(); ASSERT_VALID(pRibbon); CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST(CMFCRibbonSlider, pRibbon->FindByID(ID_RECT_SLIDER)); // Get current position int position =pSlider->GetPos(); return (double)position/(double)pSlider->GetRangeMax(); }
void CMainFrame::SetSliderPos (int nPos, UINT nID) { CArray<CMFCRibbonBaseElement*, CMFCRibbonBaseElement*> ar; m_wndRibbonBar.GetElementsByID (nID, ar); for (int i = 0; i < ar.GetSize (); i++) { CMFCRibbonSlider* pSlider = DYNAMIC_DOWNCAST (CMFCRibbonSlider, ar[i]); if (pSlider != NULL) { if (pSlider->GetPos () != nPos) { pSlider->SetPos (nPos); } } } }