MFC add scrollbar to CWnd member

12,106

Solution 1

Enabling the scroll bars isn't enough. You have to react to the window messages WM_HSCROLLand WM_VSCROLL. Using the GetScrollInfo method you get the position (value) of the scroll bars and then you draw your window content according to this position.

Solution 2

Look up some scroll bar tutorials such as http://www.codeproject.com/KB/dialog/scrolling_support.aspx . In essence, dwo's comment above is what you need to do - handle those messages and set the virtual client area size.

Share:
12,106
Tal
Author by

Tal

Updated on June 04, 2022

Comments

  • Tal
    Tal almost 2 years


    I have a member of CWnd class name mywindow
    and i want to add to it a scroll-bar.
    how i can do it?

    i try already to do:

    mywindow.EnableScrollBarCtrl(SB_BOTH,TRUE);
    

    it display both Horizontal and Vertical scroll-bars,
    but i cannot push the buttons or move the scroll-bars.
    i try also after the first command:

    mywindow.EnableScrollBar(SB_BOTH,ESB_ENABLE_BOTH);
    

    and it change nothing.

    can someone could show me a simple example how to add scroll-bar to this member?

    thanks a lot,
    Tal