Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scroll Bar Control
Message
 
To
31/05/2001 00:09:22
Jimi Lee
Pop Electronic Products Ltd.
Hong Kong, Hong Kong
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00512576
Message ID:
00513033
Views:
20
This message has been marked as the solution to the initial question of the thread.
>Hey Peter,
>
>Oh you have did it before? Can I have some more detail please? Were you using ActivX? or what? I'd like to have a try but, does it require very good technic?
>
>thank a lot!
>
>
>>Haha, I come from VFP5, and guess what ? no Scrollbars there, so you have to make them yourself. So we did (few hours).
>>This combined with a few containers on the form and you can perfectly divide the form in a scrollable - and non-scollable part. Looks very fresh by the way. Can also be very well used to give the form a header which contains info which is always there, even when scrolling (vertically). There are many more benefits.
>>Please note that when you really do this (may take you a week getting your hairs out due to the refresh-methods reacting to eachother), you also have to fuzz around with Pageframes not anticipating on this kinda stuff. This too can rather easy be accomplished. However ...
>>
>>Did you think of having the buttons on a toolbar ?
>>Once you start on this one, anticipate on having the toolbar docked (if docked) at the right side of the screen; all other positions imply unsolvable (?) anomalies in VFP, not anticipating on many changes of the toolbar (flickering). Even at the right side, it 'll take you a week only to get the flickering away, but I'll help you once you decide for this solution.
>>
>>By the way, we use both solutions at a time; gives a hell of free space.


Jimi,

I hope it's allowed to help you with some general tips;

Nope, no ActiveX;
Create a Scrollbar-class (Container) with in there a container for the bar, and the two scroll-buttons (CommandButtons). Within the bar-container have a container for the drag-button (?).

The buttons must be cut from an existing formal scrollbar, and be pasted into the container-form.

Note, my example is about the vertical scrollbar.

You won't understand it (I show too few) but it 'll give you the idea)
However, I dis how all the methods used (I hope).

Here's the MouseDown-method for the ScrollUp-button :
LPARAMETERS nButton, nShift, nXCoord, nYCoord

THIS.Parent.Change = THIS.Parent.SmallChange
THIS.Parent.timScrollUp.Interval = THIS.Parent.TimerInterval
and here for the MouseUp
LPARAMETERS nButton, nShift, nXCoord, nYCoord

THIS.Parent.timScrollUp.Interval = 0
Here's the resize of the highest container :
(note : there are some hard-coded figures here (like the 17) which anticipate on the physical width etc. of the bar which may be seen as fixed)
THIS.cmdScrollUp.Height = SYSMETRIC(6)
THIS.cmdScrollUp.Width = THIS.Width - 2
THIS.cmdScrollUp.Top = 0
THIS.cmdScrollUp.Left = 0

THIS.cmdScrollDown.Height = SYSMETRIC(6)
THIS.cmdScrollDown.Width = THIS.Width - 2
THIS.cmdScrollDown.Top = THIS.Height - THIS.cmdScrollDown.Height
THIS.cmdScrollDown.Left = 0

THIS.cntScroll.Height = THIS.Height - THIS.cmdScrollUp.Height;
  - THIS.cmdScrollDown.Height - 1

THIS.cntScroll.Width = THIS.Width - 2
THIS.cntScroll.Top = THIS.cmdScrollUp.Height + 1
THIS.cntScroll.Left = 0

THIS.LeftLine.Top = THIS.cntScroll.Top - 17
THIS.RightLine.Top = THIS.cntScroll.Top - 17

THIS.LeftLine.Height  = THIS.Height + 17
THIS.RightLine.Height = THIS.Height + 17

THIS.cntScroll.cmdScroll.Width = THIS.cntScroll.Width

THIS.SetBar(THIS.Value)
The SetBar-method :
PARAMETERS nValue

IF nValue > THIS.Maximum
	nValue = THIS.Maximum
ENDIF

IF nValue < THIS.Minimum
	nValue = THIS.Minimum
ENDIF

THIS.Value = nValue

THIS.cntScroll.cmdScroll.Top = CEILING(THIS.Value * (THIS.cntScroll.Height;
   - THIS.cntScroll.cmdScroll.Height) / THIS.Maximum)
The MouseDown for the DragButton :
LPARAMETERS nButton, nShift, nXCoord, nYCoord

IF nButton = 1 THEN
	THIS.Parent.Parent.ScrollY = nYCoord - THIS.Parent.Top - THIS.Top
ENDIF
The MouseMove for it :
LPARAMETERS nButton, nShift, nXCoord, nYCoord

LOCAL nValue

IF nButton = 1 THEN

	IF THIS.Top >= 0 AND THIS.Top <= THIS.Parent.Height - THIS.Height THEN
		THIS.Top = nYCoord - THIS.Parent.Top - THIS.Parent.Parent.ScrollY
	ELSE
		IF THIS.Top < 0 THEN
			THIS.Top = 0
		ENDIF
		IF THIS.Top > THIS.Parent.Height - THIS.Height THEN
			THIS.Top = THIS.Parent.Height - THIS.Height
		ENDIF
	ENDIF
		
ENDIF

IF THIS.Top <= 0 THEN
	THIS.Top = 0
ENDIF
IF THIS.Top >= THIS.Parent.Height - THIS.Height THEN
	THIS.Top = THIS.Parent.Height - THIS.Height
ENDIF

nValue = FLOOR((THIS.Parent.Parent.Maximum - THIS.Parent.Parent.Minimum) / ;
	(THIS.Parent.Height - THIS.Height) * THIS.Top)
THIS.Parent.Parent.SetBar(nValue)
And the MouseUp :
LPARAMETERS nButton, nShift, nXCoord, nYCoord

IF THIS.Top <= 0 THEN
	THIS.Top = 0
ENDIF
IF THIS.Top >= THIS.Parent.Height - THIS.Height THEN
	THIS.Top = THIS.Parent.Height - THIS.Height
ENDIF
Timer for ScrollUp button :
THIS.Parent.SetBar(THIS.Parent.Value - THIS.Parent.Change)
Note it needs two shapes on the left and right to let it look real.

Now you drag this class on any form and position it in the Resize of this form.
Note : We've done this in the Resize which may not be the best idea and creates the hair-out part. Maybe it's better to have a custom method which is called explicitly.

In our situation we have the following additional methods in the Scrollbar class once being on the form :

Moved on cmdScroll :
IF NOT TYPE('THISFORM.cntData.cntForm') = 'U'
	THISFORM.cntData.cntForm.Top = -THIS.Parent.Parent.Value
ENDIF
Click on cmdScrollUp :
*** After the ScrollButton is Clicked, thus Button has the Focus;
*** Give it back to the original Control.

DODEFAULT()                                    && Performs Scrolling.

THISFORM.cntData.cntForm.&HASFOC..SetFocus()   && Give Focus to original Control.
This is about all there to it. But again, the main part will be the positioning of the Scollbar, the Height of it etc. once the Form is being resized.
Note the THISFORM.cntData.cntForm, where the cntData is the complete part of the form, and the cntForm the visible part.
Note that the movement from one Control to the other, automatically scrolles the visible part of the form.

Sorry to be so extensive, while it won't be much understandable.
However, wanted to help you a bit.

Regards,
Previous
Reply
Map
View

Click here to load this message in the networking platform