Luis Calderon
Luis Calderon

Reputation: 3

MFC - How can I add a spin control to a ribbonbar

I'm using a ribbon style application and I can't seem to find a way to add a spin control to my ribbonbar. In the list of controls of my toolbox there seems to be a spinEdit control but when I add it to the ribbon bar it looks like a ribbonEdit control without showing the up and down buttons that are supposed to be embedded with it. It's there a way to enable this control to behave like a spinEdit or does this control not work at all? Thanks in advance.

Upvotes: 0

Views: 982

Answers (2)

chandrodaya singh
chandrodaya singh

Reputation: 1

I have created one spinner on Ribbon bar through Ribbon resource toolbox in MFC SDI C++ application and I am using visual studio 2015

I got Ribbon access with the help of below code

// Get the Ribbon bar and find the Spinner button by command ID
CMFCRibbonBar* pRibbonBar = GetRibbonBar();

if (pRibbonBar != nullptr)
 {
  // Access the spinner controls
  CMFCRibbonEdit* pSpin = 
  (CMFCRibbonEdit*)m_wndRibbonBar.FindByID(ID_SPIN);
  if (pSpin)
  {
   pSpin->EnableSpinButtons(0.00f, 50.00f);  // Set range 0 to 50
  }
 }

now what happening spinner upper and down arrow when click then by default taking step increment/decrement with 1.0 but I need step increment/decrement with floating value 0.10 instead of 1, Please see in MS Word where the same happening increment/decrement with floating value 0.10 please go to in MS Word.............

Layout tab-> Paragraph->Indent spinner, I need the same increment/decrement with 0.10, instead of 1.0 increment

I tried too much but not got any ideas for ribbon spinner customize step control with floating value 0.10, if anyone know about this then pls share the code.

Upvotes: 0

Roel
Roel

Reputation: 19642

Call EnableSpinButtons() on the edit control - http://msdn.microsoft.com/en-us/library/vstudio/bb982261.aspx . Instantiate it like this:

CMFCRibbonEdit* edit = new CMFCRibbonEdit(ID_SOME_ID, 75);
edit->EnableSpinButtons(10, 20);
pPanel->Add(edit);

Upvotes: 0

Related Questions