Reputation: 1433
In Google Chrome when you click the mouse wheel button you get this cursor:
And then you are able to scroll to all possible directions, when you move around with your mouse...
IE also has this, but only moves up and down:
Is there any component for Delphi that can do this? (for a TScrollBox for example)
Upvotes: 3
Views: 1170
Reputation: 1433
Seems like this feature is available in RAD studio 2009 (but not in D7).
You need to use Imouse
(imouse.pas unit) and the control must have ControlStyle of csPannable.
quote:
Imouse (imouse.pas unit) is a standard implementation of scrolling with middle button (called also "mouse panning"). It's also used in RAD Studio. Imouse functionality relays on standard window scrollbars and sends WM_HSCROLL/WM_VSCROLL to the window to make it scroll. It works on every window, that have a scrollbar (e.g. TListView, TTreeView, even TForm/TFrame if AutoScroll is True and at least one scrollbar is visible).
Oh, I've forgotten one thing. Control must have csPannable in ControlStyle, but RichView hasn't by default. So, after adding Code: RichViewEdit1.ControlStyle := RichViewEdit1.ControlStyle + [csPannable];
I didn't test it though. All that is left for me is to look into the source code (When I can get my hands on copy of D2009) and maybe impliment this with D7...
Upvotes: 3
Reputation: 1667
TMemo, for example, can do that for you, provided you set its ScrollBars property to something else than ssNone. It will even adjust according to which scroll bars are enabled. Problem with TScrollBar component is that on its own it doesn't have any focusable parts and won't receive OnMouseWheel(/Up/Down) events, but its included windowed controls might. You could write a workaround for that on main form events, though. Check solutions at http://www.delphipages.com/forum/showthread.php?t=197309
EDIT: OnMouseWheel(/Up/Down) should be OnMouse(/Up/Down), thanks to @Sertac Akyuz for pointing this out ;)
Upvotes: 3