Frage


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

War es hilfreich?

Lösung

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.

Andere Tipps

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.

There must be some 'overflow' before scroll bars became active.

Write some 'sufficiently long' data in your view and the scrollbars will become active (at least, that was my experience time ago).

Usually scroll bars get handled 'automatically' from MFC components like (for instance) text editor or form view. I.e. will became visible when needed also without explicit call EnableScrollBarCtrl ...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top