SetScrollSize and FormView
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: SetScrollSize and FormView

  1. #1
    Join Date
    Jul 2016
    Posts
    21

    SetScrollSize and FormView

    Hello,

    I created a formview with nested controls. My problem is setting the correct values for vertical scroll size so that I can scroll thru the complete range of the view. At the moment, my code cannot scroll to the bottom of the view.

    My code:

    void CMyFormView::OnInitialUpdate()
    {

    CFormView::OnInitialUpdate();

    #define MM_SCALETOFIT (-1)

    CRect rectFrame;
    CFrameWnd* pFrame = GetParentFrame();
    ASSERT_VALID(pFrame);
    pFrame->GetWindowRect(rectFrame);
    CSize size = rectFrame.Size();
    SetScrollSizes(MM_TEXT, size);
    ….
    }

    Notice in the left portion of the attached screen capture that the scroll thumb occupies almost the entire vertical scrollbar which limits the range to scroll.

    I found out that if I increased the cy member of CSize, the scrollbar thumb is smaller and it now allows me to scroll down to the bottom of the formview.

    See right portion of the screen capture.

    My question is what do I need to do to set the correct value for CSize?

    I assume I will also need the same code to change the scroll size when the user resizes the frame window in the call to OnSize.

    Thank you for your assistance.
    Attached Images Attached Images  
    Last edited by robertzp; May 25th, 2017 at 11:37 PM. Reason: sorry will repost correction

  2. #2
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    696

    Re: SetScrollSize and FormView

    It depends on how it is supposed the size is needed to be set. I assume calling the same code in OnSize() is a good idea. However, if I'm not mistaken, when manually adding a scrollbar control using wizard, it automatically fits to the parent window.

  3. #3
    Join Date
    Jul 2016
    Posts
    21

    Re: SetScrollSize and FormView

    AvDav,

    The scrollbars are NOT manually created.

    They are automatically created by Visual Studio if the formview is not scaled to fit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)