Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems with MFC Ribbon edit with spin button

Problems with MFC Ribbon edit with spin button

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
12 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dansveen
    wrote on last edited by
    #1

    Hi all In my aplication menu had a ribbon edit with spin button, I'm using this:

    pEdit->EnableSpinButtons(1, 1000);

    But when I increment with up arrow over 999 the value is changed to 1,000 I used GetEditText to change this value but what I have is 1 I can't change increment or ignore ',' or remove ',' from value, that is a bug with ribbon. In old MFC application I have Spinbuttonctrl in create method I have used UDS_NOTHOUSANDS but in ribbon I don't have this option. If somebody can help me. Thank you

    A 1 Reply Last reply
    0
    • D Dansveen

      Hi all In my aplication menu had a ribbon edit with spin button, I'm using this:

      pEdit->EnableSpinButtons(1, 1000);

      But when I increment with up arrow over 999 the value is changed to 1,000 I used GetEditText to change this value but what I have is 1 I can't change increment or ignore ',' or remove ',' from value, that is a bug with ribbon. In old MFC application I have Spinbuttonctrl in create method I have used UDS_NOTHOUSANDS but in ribbon I don't have this option. If somebody can help me. Thank you

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      Not sure I understand what your problem is... When you do a GetEditText on your control you only get 1 when it should be a 1000? or you don't expect to be able to reach 1000? Can you clarify?

      P 1 Reply Last reply
      0
      • A Albert Holguin

        Not sure I understand what your problem is... When you do a GetEditText on your control you only get 1 when it should be a 1000? or you don't expect to be able to reach 1000? Can you clarify?

        P Offline
        P Offline
        Peter_in_2780
        wrote on last edited by
        #3

        Seems the comma in 1,000 is his problem (ie GetEditText reads "1,000" then parseInt() or whatever stops at the comma). If there's no suitable style/attribute on the control he's using, then I guess it requires a bit of string-munching. Cheers, Peter

        Software rusts. Simon Stephenson, ca 1994.

        D 1 Reply Last reply
        0
        • P Peter_in_2780

          Seems the comma in 1,000 is his problem (ie GetEditText reads "1,000" then parseInt() or whatever stops at the comma). If there's no suitable style/attribute on the control he's using, then I guess it requires a bit of string-munching. Cheers, Peter

          Software rusts. Simon Stephenson, ca 1994.

          D Offline
          D Offline
          Dansveen
          wrote on last edited by
          #4

          The problem is comma, when I use GetEditText() returns '1' and not '1,000', I want 1000 because I'm editing a object and when reach 1000 returns to value 1, that's wrong. I don't have parseInt() method I'm using mfc c++. thank you

          A 1 Reply Last reply
          0
          • D Dansveen

            The problem is comma, when I use GetEditText() returns '1' and not '1,000', I want 1000 because I'm editing a object and when reach 1000 returns to value 1, that's wrong. I don't have parseInt() method I'm using mfc c++. thank you

            A Offline
            A Offline
            Albert Holguin
            wrote on last edited by
            #5

            This seems like such an obvious bug... why would GetEditText() parse out the text (CString never ends on a ',' so I don't see how this bug could occur)? where are you checking your return? Maybe post your actual code and point out where you see the 1.

            D 1 Reply Last reply
            0
            • A Albert Holguin

              This seems like such an obvious bug... why would GetEditText() parse out the text (CString never ends on a ',' so I don't see how this bug could occur)? where are you checking your return? Maybe post your actual code and point out where you see the 1.

              D Offline
              D Offline
              Dansveen
              wrote on last edited by
              #6

              Hi Here is my code:

              CMFCRibbonEdit *pEdit = DYNAMIC_DOWNCAST(CMFCRibbonEdit, MyApp->GetRibbonElement(ID_RIBBON_FORMAT_WIDTH));
              if(pEdit == NULL)
              return;
              CDrawObj *pObj = (CDrawObj*)m_selection.GetHead();
              if(pObj == NULL){
              ASSERT(0);
              return;
              }
              if(_ttoi(pEdit->GetEditText()) < 1) <==== Here GetEditText() return 1 and not 1,000 I tested with MFCOffice2007Sample and they have the same problem
              return;
              this->InvalObj(pObj);
              int nDelta = _ttoi(pEdit->GetEditText()) - pObj->m_position.Width();
              if(nDelta < GetDocument()->m_size.cx){
              CRect newPosition = pObj->m_position;
              newPosition.right += nDelta;
              pObj->MoveTo(newPosition);
              }

              A 1 Reply Last reply
              0
              • D Dansveen

                Hi Here is my code:

                CMFCRibbonEdit *pEdit = DYNAMIC_DOWNCAST(CMFCRibbonEdit, MyApp->GetRibbonElement(ID_RIBBON_FORMAT_WIDTH));
                if(pEdit == NULL)
                return;
                CDrawObj *pObj = (CDrawObj*)m_selection.GetHead();
                if(pObj == NULL){
                ASSERT(0);
                return;
                }
                if(_ttoi(pEdit->GetEditText()) < 1) <==== Here GetEditText() return 1 and not 1,000 I tested with MFCOffice2007Sample and they have the same problem
                return;
                this->InvalObj(pObj);
                int nDelta = _ttoi(pEdit->GetEditText()) - pObj->m_position.Width();
                if(nDelta < GetDocument()->m_size.cx){
                CRect newPosition = pObj->m_position;
                newPosition.right += nDelta;
                pObj->MoveTo(newPosition);
                }

                A Offline
                A Offline
                Albert Holguin
                wrote on last edited by
                #7

                See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.

                CString ret = pEdit->GetEditText(); //<-- check the returned string
                ret.Remove(','); //<-- Now you can convert this

                D P 2 Replies Last reply
                0
                • A Albert Holguin

                  See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.

                  CString ret = pEdit->GetEditText(); //<-- check the returned string
                  ret.Remove(','); //<-- Now you can convert this

                  D Offline
                  D Offline
                  Dansveen
                  wrote on last edited by
                  #8

                  Thank you Now is working but when I click in Up Arrow the increment shows 1,000, 1,001, 1,002 and when I change focus shows the correct value. Thanks for all

                  A 1 Reply Last reply
                  0
                  • D Dansveen

                    Thank you Now is working but when I click in Up Arrow the increment shows 1,000, 1,001, 1,002 and when I change focus shows the correct value. Thanks for all

                    A Offline
                    A Offline
                    Albert Holguin
                    wrote on last edited by
                    #9

                    that's a different issue, post as new question pls... :)

                    D 1 Reply Last reply
                    0
                    • A Albert Holguin

                      See... you're problem is probably with the conversion of the CString to an integer... place pEdit->GetEditText() on its own line and look at the text returned. If its 1000, with or without a coma, its correct and the problem is with the function doing the conversion to integer. You can always take your returned CString and remove the ',' character before even attempting the conversion.

                      CString ret = pEdit->GetEditText(); //<-- check the returned string
                      ret.Remove(','); //<-- Now you can convert this

                      P Offline
                      P Offline
                      Peter_in_2780
                      wrote on last edited by
                      #10

                      Thanks. All fixed while I was sleeping... You've spelled out exactly what I was referring to a few message above. Cheers, Peter

                      Software rusts. Simon Stephenson, ca 1994.

                      1 Reply Last reply
                      0
                      • A Albert Holguin

                        that's a different issue, post as new question pls... :)

                        D Offline
                        D Offline
                        Dansveen
                        wrote on last edited by
                        #11

                        The problem is resolved: I used: CString str = pEdit->GetEditText(); str.Remove(`,`); pEdit->SetEditText(str); :) Thank you

                        A 1 Reply Last reply
                        0
                        • D Dansveen

                          The problem is resolved: I used: CString str = pEdit->GetEditText(); str.Remove(`,`); pEdit->SetEditText(str); :) Thank you

                          A Offline
                          A Offline
                          Albert Holguin
                          wrote on last edited by
                          #12

                          Cool... cheers! :)

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups