2

I was looking for an option to make mouse wheel work with scrollbox component, so far I got this

void __fastcall TForm1::ScrollBox1MouseWheelDown(TObject *Sender, TShiftState Shift,
          TPoint &MousePos, bool &Handled)
{
    Form1->ScrollBox1->VertScrollBar->Position++;
}

void __fastcall TForm1::ScrollBox1MouseWheelUp(TObject *Sender, TShiftState Shift,
          TPoint &MousePos, bool &Handled)
{
    Form1->ScrollBox1->VertScrollBar->Position--;
}

So far it works, but it scrolls really slow. Is there any way to make it scroll faster, or maybe even better way of handling scrolling in c++ builder?

Johan
  • 74,508
  • 24
  • 191
  • 319
Nikosis
  • 21
  • 1
  • 4

2 Answers2

1

TScrollBox in C++Builder XE2 natively supports vertical scrolling via a mouse wheel. You do not need to do anything extra to enable that behavior. I just tested it, it works fine.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • just came to say that, mark this a correct. Also tested in XE3 – Gregor Brandt Mar 28 '13 at 21:55
  • I don't know, it doesn't work for me, I placed in groupbox, oversize it, for scroll bar to appear, and nothing it doesn't work.Do you think it might have something to do with the fact that it's under Virtualbox – Nikosis Mar 30 '13 at 16:49
  • Interesting: I did my original test in XE3, now in XE7 I cannot get the scroll wheel to work. This is a bog standard TScrollBox with a TPaint box in it. – Gregor Brandt Oct 07 '14 at 15:56
0

I use C++Builder XE2 and it doesn't support scrolling the TScrollBox natively, so I use your approach, but just the OnMouseWheel event, scrolling down if WheelDelta is lower than 0, and scrolling up if it is higher than 0.

About the scrolling speed, can't you just add/subtract a higher constant to the Position variable? Like in:

Form1->ScrollBox1->VertScrollBar->Position += 3; 
gabrielmdu
  • 225
  • 2
  • 11