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. How to "attach" a CScrollBar to a editbox?

How to "attach" a CScrollBar to a editbox?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
9 Posts 2 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.
  • C Offline
    C Offline
    Chambers
    wrote on last edited by
    #1

    Hi all, I just want to know what the easiest way is to have an edit box (which represents an integer, say width/height) and the arrow buttons, which upon pressing up increments the editbox value by one, and upon pressing down decrements the editbox by one? I have tried mercilessly to do this, but alas I have failed. Thanks guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

    R 1 Reply Last reply
    0
    • C Chambers

      Hi all, I just want to know what the easiest way is to have an edit box (which represents an integer, say width/height) and the arrow buttons, which upon pressing up increments the editbox value by one, and upon pressing down decrements the editbox by one? I have tried mercilessly to do this, but alas I have failed. Thanks guys, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Use a CSpinButtonCtrl. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

      C 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Use a CSpinButtonCtrl. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

        C Offline
        C Offline
        Chambers
        wrote on last edited by
        #3

        Cheers for the response. OK, I see where your going with this, but I`m still unsure as to how to link it to the edit box? I`m using a dialog box to house this control. I have so far placed the edit box and the CSpinButtonCtrl on the dialog. I have created variables for both in the dialog framework (for the CSpin a DDX control is used). Do I still have to "create" the CSpin thingy? or do I link it some other way? Many Thanks, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

        R 1 Reply Last reply
        0
        • C Chambers

          Cheers for the response. OK, I see where your going with this, but I`m still unsure as to how to link it to the edit box? I`m using a dialog box to house this control. I have so far placed the edit box and the CSpinButtonCtrl on the dialog. I have created variables for both in the dialog framework (for the CSpin a DDX control is used). Do I still have to "create" the CSpin thingy? or do I link it some other way? Many Thanks, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          ****Chambers wrote: or do I link it some other way? Yes. Ensure that the ids of the controls are consecutive (spin control > edit control), then set the "AutoBuddy" property of the spin control in the resource editor. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

          C 1 Reply Last reply
          0
          • R Ravi Bhavnani

            ****Chambers wrote: or do I link it some other way? Yes. Ensure that the ids of the controls are consecutive (spin control > edit control), then set the "AutoBuddy" property of the spin control in the resource editor. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

            C Offline
            C Offline
            Chambers
            wrote on last edited by
            #5

            What do I set the "Auto Buddy" too? the ID value of the edit box I presume? If this is right don`t worry about answering it, I`ll delete it if it works now. Thanks again, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

            R 1 Reply Last reply
            0
            • C Chambers

              What do I set the "Auto Buddy" too? the ID value of the edit box I presume? If this is right don`t worry about answering it, I`ll delete it if it works now. Thanks again, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              What I meant was check the "AutoBuddy" property of the spin control in the resource editor. If your ids are consecutive, the spin control will automatically become the buddy of the previous edit control, which causes them to be linked. Also, you can position an autobuddy spin control anywhere in the dialog - it will be automagically rendered inside the edit control. So remember to account for the extra space when sizing the edit control. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

              C 1 Reply Last reply
              0
              • R Ravi Bhavnani

                What I meant was check the "AutoBuddy" property of the spin control in the resource editor. If your ids are consecutive, the spin control will automatically become the buddy of the previous edit control, which causes them to be linked. Also, you can position an autobuddy spin control anywhere in the dialog - it will be automagically rendered inside the edit control. So remember to account for the extra space when sizing the edit control. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

                C Offline
                C Offline
                Chambers
                wrote on last edited by
                #7

                Right, I`ve managed to get them linked, finally. I had to enter the resource editor and swap the order of the ids around because it kept attaching to the save button i had (which is exactly what you said to do Ravi). However, the numbers go UP when i press the DOWN button, and visa versa. How do I swap them around, so that the up button makes the integer go UP, not blinking down? Cheers for your help getting me this far Ravi, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

                R 1 Reply Last reply
                0
                • C Chambers

                  Right, I`ve managed to get them linked, finally. I had to enter the resource editor and swap the order of the ids around because it kept attaching to the save button i had (which is exactly what you said to do Ravi). However, the numbers go UP when i press the DOWN button, and visa versa. How do I swap them around, so that the up button makes the integer go UP, not blinking down? Cheers for your help getting me this far Ravi, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

                  R Offline
                  R Offline
                  Ravi Bhavnani
                  wrote on last edited by
                  #8

                  Yes, that's annoying! I suppose you could override the spin control's notifications and manually set the edit control to do the opposite. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                  C 1 Reply Last reply
                  0
                  • R Ravi Bhavnani

                    Yes, that's annoying! I suppose you could override the spin control's notifications and manually set the edit control to do the opposite. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                    C Offline
                    C Offline
                    Chambers
                    wrote on last edited by
                    #9

                    I found an easier way. MSDN help says that, by default, the CSpin thingy's range is set to Min:100 Max:0, and by clicking the down arrow sends the current value nearer the minimum value, which is why it goes up, its heading for 100. All I did to get it to work properly was call :

                    CDialog::DoDataExchange(etc.)
                    {
                    ... min , max
                    myCSpinThingy.SetRange(0 , 10);
                    }

                    and it worked no problem. Just thought I`d let you know, since I wouldn`t have got there in the end if it weren't for you, Cheers Ravi, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:

                    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