| | |
Scrolling ScrollBox By Mouse
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2007
Posts: 36
Reputation:
Solved Threads: 6
Hi
I Have Some Problem with ScrollBox As Below
1- If I Put a ScrollBox On a form and Put Some Objects such as TButton,TImage , .... on it If I move an object to right (or down) and trepass right side (or Down) of ScrollBox the horizontal (or vertical) scrollBar will be appear But If Imove an object to left (or up) and trepass left side (or top) of ScrollBox no scrollBar will be appear
2- how cane I Scroll Vertical ScrollBar of the ScrollBox by mose wheel (middle scrolling button of mouse)
as brief I want scroll a scrollbox vertically as same as DBGride vertical scrollBar
thanks
I Have Some Problem with ScrollBox As Below
1- If I Put a ScrollBox On a form and Put Some Objects such as TButton,TImage , .... on it If I move an object to right (or down) and trepass right side (or Down) of ScrollBox the horizontal (or vertical) scrollBar will be appear But If Imove an object to left (or up) and trepass left side (or top) of ScrollBox no scrollBar will be appear
2- how cane I Scroll Vertical ScrollBar of the ScrollBox by mose wheel (middle scrolling button of mouse)
as brief I want scroll a scrollbox vertically as same as DBGride vertical scrollBar
thanks
•
•
Join Date: Nov 2009
Posts: 40
Reputation:
Solved Threads: 3
0
#2 28 Days Ago
1) ScrollBox, as any other componet, use positive positions, having the origin (0,0) on top-left, so you can't place anything above the top, it would be a negative value on top property, so it will be clipped away.
The only work around -if you realy need to do this- is that, when a component is placed above top, let say you need a top=-10, then set top to 0 on this objet and, on ALL other objects in your scrollbox, add 10 to theirs top, so relative positions remain as desired (grafically no scroll bar, but the "backgroud" fall down with all your component on it).
2) Step by step:
-Place a TApplicationEvents on your form, i named it MouseWheelEvent.
-Define a event handler on it for the "OnMessage" event to handle it all, it should look like this:
procedure TGPagView.MouseWheelEventMessage(var Msg: tagMSG;
var Handled: Boolean);
var i: SmallInt;
begin
//Form is active?
if Active then begin
//Was it a wheel move?
if (Msg.message = WM_MOUSEWHEEL) then begin
//Extract mouse wheel movement (positive, negative, small, etc)
i:= HiWord(Msg.wParam);
//Cancel the message so it don't do anything more
Handled:= true;
//Do whatever you need using i as a wheel movement measure...
Form.Caption:= 'Wheel moved '+IntToStr(i)+' ticks.';
end;
end;
end;
Important notice: While the form is not totally freed, it will catch events and try to process them, so be aware, becuase after usual form.close moving the wheel WILL raise errors!
You need to place a "Action:= caFree;" on the FormClose event or you will get crazy debuging it (I did)!
The only work around -if you realy need to do this- is that, when a component is placed above top, let say you need a top=-10, then set top to 0 on this objet and, on ALL other objects in your scrollbox, add 10 to theirs top, so relative positions remain as desired (grafically no scroll bar, but the "backgroud" fall down with all your component on it).
2) Step by step:
-Place a TApplicationEvents on your form, i named it MouseWheelEvent.
-Define a event handler on it for the "OnMessage" event to handle it all, it should look like this:
procedure TGPagView.MouseWheelEventMessage(var Msg: tagMSG;
var Handled: Boolean);
var i: SmallInt;
begin
//Form is active?
if Active then begin
//Was it a wheel move?
if (Msg.message = WM_MOUSEWHEEL) then begin
//Extract mouse wheel movement (positive, negative, small, etc)
i:= HiWord(Msg.wParam);
//Cancel the message so it don't do anything more
Handled:= true;
//Do whatever you need using i as a wheel movement measure...
Form.Caption:= 'Wheel moved '+IntToStr(i)+' ticks.';
end;
end;
end;
Important notice: While the form is not totally freed, it will catch events and try to process them, so be aware, becuase after usual form.close moving the wheel WILL raise errors!
You need to place a "Action:= caFree;" on the FormClose event or you will get crazy debuging it (I did)!
•
•
Join Date: Jun 2007
Posts: 36
Reputation:
Solved Threads: 6
0
#3 27 Days Ago
•
•
•
•
1) ScrollBox, as any other componet, use positive positions, having the origin (0,0) on top-left, so you can't place anything above the top, it would be a negative value on top property, so it will be clipped away.
The only work around -if you realy need to do this- is that, when a component is placed above top, let say you need a top=-10, then set top to 0 on this objet and, on ALL other objects in your scrollbox, add 10 to theirs top, so relative positions remain as desired (grafically no scroll bar, but the "backgroud" fall down with all your component on it).
2) Step by step:
-Place a TApplicationEvents on your form, i named it MouseWheelEvent.
-Define a event handler on it for the "OnMessage" event to handle it all, it should look like this:
procedure TGPagView.MouseWheelEventMessage(var Msg: tagMSG;
var Handled: Boolean);
var i: SmallInt;
begin
//Form is active?
if Active then begin
//Was it a wheel move?
if (Msg.message = WM_MOUSEWHEEL) then begin
//Extract mouse wheel movement (positive, negative, small, etc)
i:= HiWord(Msg.wParam);
//Cancel the message so it don't do anything more
Handled:= true;
//Do whatever you need using i as a wheel movement measure...
Form.Caption:= 'Wheel moved '+IntToStr(i)+' ticks.';
end;
end;
end;
Important notice: While the form is not totally freed, it will catch events and try to process them, so be aware, becuase after usual form.close moving the wheel WILL raise errors!
You need to place a "Action:= caFree;" on the FormClose event or you will get crazy debuging it (I did)!
Thank you for your attention. But it is not what that I want!
I can using ScrolBy ruttine of ScrollBox for Scrolling ScrollBox By Mouse Wheel But it will scroll indefinitly so if you try to scroll ScrollBox By cliking mouse on Scroll Bar it will Scroll Properly.
I want scroll ScrollBox By mouse wheel as same as Scrolling by Klicking on ScrollBar.
I send you a Sample code that you can see what happend when using mouse wheel
thanks
•
•
Join Date: Nov 2009
Posts: 40
Reputation:
Solved Threads: 3
0
#4 27 Days Ago
I have seen your example: You want the scroll bar to detect and display correctly when button.top=-55, but you simple can't, negative tops are objets OUT of the scrollbox, it can hold components with top as big as needed, and the scroll bar will reflect it, but negative tops or lefts are simple object clipped away, out of reach.
Just try to set top to -55 visually on the IDE, the component disapear, there is nothing above the top.
I would just avoid this situation: If the most upper componet you have on your scrollbox has a top of 35, for instance, get this value -in a for loop of all its components, for instance- and put on a variable. Each time you scroll, inc. or dec. this value, and don't let scroll up if this value is zero. This will make objets to stop on top of the panel.
Just try to set top to -55 visually on the IDE, the component disapear, there is nothing above the top.
I would just avoid this situation: If the most upper componet you have on your scrollbox has a top of 35, for instance, get this value -in a for loop of all its components, for instance- and put on a variable. Each time you scroll, inc. or dec. this value, and don't let scroll up if this value is zero. This will make objets to stop on top of the panel.
![]() |
Similar Threads
- problem with playing swf file on browser (Graphics and Multimedia)
- Best mouse over image scrolling (HTML and CSS)
- Need Iframe to stop scrolling. (HTML and CSS)
- Mouse and Scrolling Problems (Windows NT / 2000 / XP)
- "sponsored link" box too small for mozilla (DaniWeb Community Feedback)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: How i can read rs232c in delphi
- Next Thread: Word search puzzle in Delphi?
| Thread Tools | Search this Thread |





