CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Question Problem with ScrollBar on SDI application

    Hi All,
    I have created a SDI application. It have a horizontal splitter in middle for getting two views.
    There is one dialog is attached to the lower view for adding few controls like static control, edit box, combo box etc.
    My Lower view class is inherited from CFormView class.
    As I move the splitter downwards, automatically the vertical scrollBar appears.
    I want to create my custom scroll bar instead of that MFC ScrollBar.
    So I have two questions to ask:
    1. How can I stop this appearance of this default scrollBar on moving of splitter?
    2. How can I add my custom ScrollBar to my view.

    Please guide.

    Thanks in Advance,
    Mayank

  2. #2
    Join Date
    Jan 2009
    Posts
    399

    Re: Problem with ScrollBar on SDI application

    Modifying the existing scrollbar could be an option ?

  3. #3
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Problem with ScrollBar on SDI application

    Quote Originally Posted by mesajflaviu View Post
    Modifying the existing scrollbar could be an option ?
    Yes ofcourse.

    But I am not able to find which function gets called as I move my splitter downwards and suddenly the scroll bar gets appeared.
    Which message create the scrollbar?

    Please can you guide me how to proceed for modifying the existing scrollbar.

    Thanks in Advance,
    Mayank

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Problem with ScrollBar on SDI application

    Quote Originally Posted by mayank_3103 View Post
    But I am not able to find which function gets called as I move my splitter downwards and suddenly the scroll bar gets appeared.
    Which message create the scrollbar?
    It happens because the size of the frame around your formview (in your case - the height) became smaller than the size of the form itself.
    To remove the scrollbar(s) try to call
    CScrollView::SetScaleToFitSize
    or
    CScrollView::SetScrollSizes
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Problem with ScrollBar on SDI application

    Quote Originally Posted by VictorN View Post
    It happens because the size of the frame around your formview (in your case - the height) became smaller than the size of the form itself.
    To remove the scrollbar(s) try to call
    CScrollView::SetScaleToFitSize
    or
    CScrollView::SetScrollSizes
    Actually my requirement is to use my ScrollBar instead of that default ScrollBar. I have a dll in which the custom drawn ScrollBar is implemented. And that Custom drawn scrollBar I am not able to apply on my SDI application. the default scrollBar is appearing everytime.

    Please guide how can I implement my scrollBar in SDI application instead of default one.

    Thanks.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Problem with ScrollBar on SDI application

    Have a look at this Q&A in MSJ
    Victor Nijegorodov

  7. #7
    Join Date
    Jan 2009
    Posts
    399

    Re: Problem with ScrollBar on SDI application

    I just work on the same task, I give you what I have done already: (my task is to modify the scrollbar color and style to CGridCtrl) .... my trial is to work on VisualStyle:
    https://msdn.microsoft.com/en-us/lib...85).aspx<br />
    https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
    in OnDraw:
    Code:
    void CGridCtrlExt::OnDraw(CDC* pDC)
    {
        // draw the grid and after that:
    
       HTHEME hTheme = OpenThemeData(m_hWnd, L"WINDOW");
    //   HTHEME hTheme = OpenThemeData(m_hWnd, L"MFCGridCtrl");
       if(NULL != hTheme)
       {
          CScrollBar* pScrollbar = GetScrollBarCtrl(SB_VERT);
          if(NULL != pScrollbar->GetSafeHwnd()) // <-- is always null
          {
             CRect rect;
             pScrollbar->GetWindowRect(&rect);
             pDC->FillSolidRect(&rect, RGB(255, 255, 0));
             DrawThemeBackground(hTheme, pDC->GetSafeHdc(), WP_VERTSCROLL, VSS_NORMAL, &rect, NULL);
          }
          CloseThemeData(hTheme);
       }
    }

  8. #8
    Join Date
    Jan 2009
    Posts
    399

    Re: Problem with ScrollBar on SDI application

    Soon as I finish my task, I will give you the solution ...

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured