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. troubles on using scroll bar in frame

troubles on using scroll bar in frame

Scheduled Pinned Locked Moved C / C++ / MFC
help
13 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.
  • F Offline
    F Offline
    firebolt77
    wrote on last edited by
    #1

    hi all..I want to make a dialog that can be resize with HScroll and VScroll. But when I tried the program, the dialog window can be resized, but the scroll doesn't work(I added the scroll using class wizard by right-clicking the dialog window, go to properties, and checked horizontal scroll and vertical scroll). Pls help... thx.

    C 1 Reply Last reply
    0
    • F firebolt77

      hi all..I want to make a dialog that can be resize with HScroll and VScroll. But when I tried the program, the dialog window can be resized, but the scroll doesn't work(I added the scroll using class wizard by right-clicking the dialog window, go to properties, and checked horizontal scroll and vertical scroll). Pls help... thx.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Scroll doesn't work by itself, you need to catch the scroll events, and make sure your code adjusts it's display accordingly. You also need to set the range of the scroll bars. Christian Graus - Microsoft MVP - C++

      F 1 Reply Last reply
      0
      • C Christian Graus

        Scroll doesn't work by itself, you need to catch the scroll events, and make sure your code adjusts it's display accordingly. You also need to set the range of the scroll bars. Christian Graus - Microsoft MVP - C++

        F Offline
        F Offline
        firebolt77
        wrote on last edited by
        #3

        how to implement it? Can u give some tutorials,articles,or some link that can be helpful..pls thx

        C 1 Reply Last reply
        0
        • F firebolt77

          how to implement it? Can u give some tutorials,articles,or some link that can be helpful..pls thx

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          What version of VC are you using ? Whatever it is, you can set an event handler for each of the two scroll events ( but if I know which one, I can tell you exactly where ), and then you force a redraw with Invalidate(), and your drawing code takes the scroll position into account. I don't know of any tutorials, off hand, sorry. I'd be surprised if this site didn't have any. Christian Graus - Microsoft MVP - C++

          F 1 Reply Last reply
          0
          • C Christian Graus

            What version of VC are you using ? Whatever it is, you can set an event handler for each of the two scroll events ( but if I know which one, I can tell you exactly where ), and then you force a redraw with Invalidate(), and your drawing code takes the scroll position into account. I don't know of any tutorials, off hand, sorry. I'd be surprised if this site didn't have any. Christian Graus - Microsoft MVP - C++

            F Offline
            F Offline
            firebolt77
            wrote on last edited by
            #5

            I'm using VC 6.0. I already make the event handler. On where I should write my drawing code? Btw...what is the keyword for finding thw tutorials(I try "repainting window" keyword, but I didn't find any suitable articles) thx...

            C 1 Reply Last reply
            0
            • F firebolt77

              I'm using VC 6.0. I already make the event handler. On where I should write my drawing code? Btw...what is the keyword for finding thw tutorials(I try "repainting window" keyword, but I didn't find any suitable articles) thx...

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              firebolt77 wrote: On where I should write my drawing code Drawing code is ALWAYS in OnPaint. Invalidate(); is all the code you need to put in a scroll event to force a repaint. Christian Graus - Microsoft MVP - C++

              F 1 Reply Last reply
              0
              • C Christian Graus

                firebolt77 wrote: On where I should write my drawing code Drawing code is ALWAYS in OnPaint. Invalidate(); is all the code you need to put in a scroll event to force a repaint. Christian Graus - Microsoft MVP - C++

                F Offline
                F Offline
                firebolt77
                wrote on last edited by
                #7

                Thx...but I'm still confuse on the drawing code :) I'm still new in MFC so I'm still lack of knowledge in MFC thx anyway..

                C 1 Reply Last reply
                0
                • F firebolt77

                  Thx...but I'm still confuse on the drawing code :) I'm still new in MFC so I'm still lack of knowledge in MFC thx anyway..

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Well, what are you drawing ? How do you draw it now ? Christian Graus - Microsoft MVP - C++

                  F 1 Reply Last reply
                  0
                  • C Christian Graus

                    Well, what are you drawing ? How do you draw it now ? Christian Graus - Microsoft MVP - C++

                    F Offline
                    F Offline
                    firebolt77
                    wrote on last edited by
                    #9

                    just ordinary dialog box with tab control, tree control, button, edit box, etc. I want the dialog box can be resize to smaller size, and I can use the scroll bar to see all of the frame. Sorry for the bad english...but I hope you understand what I mean :) thx..

                    C 1 Reply Last reply
                    0
                    • F firebolt77

                      just ordinary dialog box with tab control, tree control, button, edit box, etc. I want the dialog box can be resize to smaller size, and I can use the scroll bar to see all of the frame. Sorry for the bad english...but I hope you understand what I mean :) thx..

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      Oh, OK. Well, I'd have thought a CFormView would handle that by itself. There's no painting involved here - your controls all need to be on some sort of control that you can position, otherwise you need to call SetWindowPos on all of them to move them, which is kind of ugly. Christian Graus - Microsoft MVP - C++

                      F 1 Reply Last reply
                      0
                      • C Christian Graus

                        Oh, OK. Well, I'd have thought a CFormView would handle that by itself. There's no painting involved here - your controls all need to be on some sort of control that you can position, otherwise you need to call SetWindowPos on all of them to move them, which is kind of ugly. Christian Graus - Microsoft MVP - C++

                        F Offline
                        F Offline
                        firebolt77
                        wrote on last edited by
                        #11

                        hmm..but I'm using CDialog base class. Can I use the method? thx..

                        C 1 Reply Last reply
                        0
                        • F firebolt77

                          hmm..but I'm using CDialog base class. Can I use the method? thx..

                          C Offline
                          C Offline
                          Christian Graus
                          wrote on last edited by
                          #12

                          Yeah, I guessed that. You need to do what I said as an alternative, get a blank control ( that is, one that gives you a surface, but nothing on it, probably the control base class ), set out all your controls on that, and move it's location using SetWindowPos in response to the scroll bars. So the scroll range for X is the width of your control - the width of the window, and the same for the Y. Then when your scroll event occurs, you set the window position of the control to be the offset of the scroll pos, so if hte X scrollbar is set to 20, then the X position is -20, so the first twenty pixels of the control are to the left of the left edge of the main window. Christian Graus - Microsoft MVP - C++

                          F 1 Reply Last reply
                          0
                          • C Christian Graus

                            Yeah, I guessed that. You need to do what I said as an alternative, get a blank control ( that is, one that gives you a surface, but nothing on it, probably the control base class ), set out all your controls on that, and move it's location using SetWindowPos in response to the scroll bars. So the scroll range for X is the width of your control - the width of the window, and the same for the Y. Then when your scroll event occurs, you set the window position of the control to be the offset of the scroll pos, so if hte X scrollbar is set to 20, then the X position is -20, so the first twenty pixels of the control are to the left of the left edge of the main window. Christian Graus - Microsoft MVP - C++

                            F Offline
                            F Offline
                            firebolt77
                            wrote on last edited by
                            #13

                            ok thx...I will try it

                            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