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. Form Scrolling Problem

Form Scrolling Problem

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
5 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.
  • R Offline
    R Offline
    RuiSantiago
    wrote on last edited by
    #1

    Hi, for 3 days i'm trying to make my form resizable. Well, in desing mode, as my form has the VScroll property true, i increase the bottom of the form and then when i run it the scrollbar appears and works. I want to do that but by code, to increase the form's bottom as i'm going to dinamically filling it with objects, i'm doing like: CRect myRect; for (int i=0;i<100;i++) { caramba[i] = new CStatic; g.Format("%d", i); caramba[i]->Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this); myRect.bottom+=20; } MoveWindow(myRect.left, myRect.top, myRect.right, myRect.bottom); this->GetParentFrame()->RecalcLayout(); The objects are drawn in the form until number 65, well until the regular size of the form, and the scrollbar do not appear. How can i make the VScrollbar to appear as the form size increases? Thank you in advance

    L 1 Reply Last reply
    0
    • R RuiSantiago

      Hi, for 3 days i'm trying to make my form resizable. Well, in desing mode, as my form has the VScroll property true, i increase the bottom of the form and then when i run it the scrollbar appears and works. I want to do that but by code, to increase the form's bottom as i'm going to dinamically filling it with objects, i'm doing like: CRect myRect; for (int i=0;i<100;i++) { caramba[i] = new CStatic; g.Format("%d", i); caramba[i]->Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this); myRect.bottom+=20; } MoveWindow(myRect.left, myRect.top, myRect.right, myRect.bottom); this->GetParentFrame()->RecalcLayout(); The objects are drawn in the form until number 65, well until the regular size of the form, and the scrollbar do not appear. How can i make the VScrollbar to appear as the form size increases? Thank you in advance

      L Offline
      L Offline
      lucy 0
      wrote on last edited by
      #2

      I think you need to set the scroll size. Try this function: SetScrollSizes()

      R 1 Reply Last reply
      0
      • L lucy 0

        I think you need to set the scroll size. Try this function: SetScrollSizes()

        R Offline
        R Offline
        RuiSantiago
        wrote on last edited by
        #3

        Thank you Lucy, i tried your suggestion, i did like: CRect myRect; CSize mySiz:omg:e; this->GetClientRect(&myRect); mySize=myRect.Size(); for (int i=0;i<100;i++) { caramba[i] = new CStatic; g.Format("%d", i); caramba[i]->Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this); myRect.bottom+=20; } MoveWindow(myRect.left, myRect.top, myRect.right, myRect.bottom); this->GetParentFrame()->RecalcLayout(); this->SetScrollSizes(MM_TEXT, mySize); this->ShowScrollBar(SB_VERT, TRUE); this->SetScaleToFitSize(mySize); Even using SetScrollSizes and ShowScroll after RecalcLayout, it apears for half a second or something, and then disapears again. I tried SetScaleToFitSize and it did not improve Why does this appends? Thank you in advance

        L 1 Reply Last reply
        0
        • R RuiSantiago

          Thank you Lucy, i tried your suggestion, i did like: CRect myRect; CSize mySiz:omg:e; this->GetClientRect(&myRect); mySize=myRect.Size(); for (int i=0;i<100;i++) { caramba[i] = new CStatic; g.Format("%d", i); caramba[i]->Create(g, WS_CHILD|WS_VISIBLE|SS_CENTER|WS_BORDER, CRect(10, i*10, 120, i*10+50), this); myRect.bottom+=20; } MoveWindow(myRect.left, myRect.top, myRect.right, myRect.bottom); this->GetParentFrame()->RecalcLayout(); this->SetScrollSizes(MM_TEXT, mySize); this->ShowScrollBar(SB_VERT, TRUE); this->SetScaleToFitSize(mySize); Even using SetScrollSizes and ShowScroll after RecalcLayout, it apears for half a second or something, and then disapears again. I tried SetScaleToFitSize and it did not improve Why does this appends? Thank you in advance

          L Offline
          L Offline
          lucy 0
          wrote on last edited by
          #4

          I am not sure. But I think you need to give the total size to SetScrollSize. that is, the size of your document. Excuse me for my poor English, let me give you an example. Say you are opening a document which will occupy a 800x600 screen. But your window is only 400x200 big. So you set the scroll size to be 800x200. And the vertical scroll bar and horizontal scroll bar will appear for your to scroll to see the other part of the contents. If you are using this->GetClientRect() to set scroll size, you are telling Windows that the screen needed is of the same size as the screen allocated. So, no scroll is necessary. Hope this helps.

          R 1 Reply Last reply
          0
          • L lucy 0

            I am not sure. But I think you need to give the total size to SetScrollSize. that is, the size of your document. Excuse me for my poor English, let me give you an example. Say you are opening a document which will occupy a 800x600 screen. But your window is only 400x200 big. So you set the scroll size to be 800x200. And the vertical scroll bar and horizontal scroll bar will appear for your to scroll to see the other part of the contents. If you are using this->GetClientRect() to set scroll size, you are telling Windows that the screen needed is of the same size as the screen allocated. So, no scroll is necessary. Hope this helps.

            R Offline
            R Offline
            RuiSantiago
            wrote on last edited by
            #5

            Sure it helped, i got it working :-D Thank you very much Lucy, i hope i can help you when you need 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