# Saturday, August 27, 2005

New Found Respect for Scrollbar Creation
Earlier this evening I decided to create a scrollbar class for use with Visual FoxPro. My requirements were that it was created purely with Visual FoxPro (didn't have any ActiveX dependecies) and that it was professional enough for use in a real world Visual FoxPro application. It is now five hours later... the class is complete and I have a new found respect for anyone who successfully creates scrollbars. This turned out to be one of the more difficult challenges I have given myself.

New VFPScrollBar Class Library
I created my scrollbar classes in a class library called vfpscrollbar.vcx. The three classes that are of note are the scrollbarhorizontal, scrollbarvertical, and the sbscrollablecontainer. The sbscrollablecontainer is an example of the types of classes that can be built using the scrollbars.

Properties and Events
The following is a list of notable properties and methods for the scrollbars:
Min - Specifies the minimum value for the scrollbar (defaults to 0)
Max - Specifies the maximum value for the scrollbar (defaults to 500)
Value - The current value of the scrollbar based on the position of the thumb/scroll box
LargeChange - The amount that is added or deducted from the scrollbar's value when the area between the thumb/scroll box and the scroll arrows is clicked
SmallChange - The amount that is added or deducted from the scrollbar's value when the scroll arrows are clicked
Change() - This event/method is fired whenever the value of the scrollbar changes
Scroll() - This event/method is fired whenever the user is moving the thumb/scroll box

When placing the scrollbar classes in a container (form or whatever), you can resize the scrollbar making it wider and/or longer. The result at design time may look a little odd (since the scroll arrows and thumb/scroll box don't resize or reposition themselves at design time, but everything will shape up at runtime. The point is, that you needn't spend a bunch of time making the scrollbars look good at design time. Just place them, resize and position the main container and run it.

Future Work and Colors
Currently the scrollbars are blue (to match Windows XP theme), but I have my eye towards eventually allowing the scrollbar classes color to be changed either with a single property setting or by checking the user's current system settings and pulling the color from there. I painstakingly created these scrollbar classes without using any image so that the colors could be easily changed on the fly without additional image resources.

I'll also be revisiting the code and refactoring portions of it. As it is now, I am burnt out on it (it was a rough five hours to get this thing to work and look right). So, don't expect a code clinic with this class... I mean it's not horrible, but I do need to take another pass through it before I will be happy with it.

Suggestions and Bug Reports Welcome
I also want to mention that a few members of the Visual FoxPro Community have started to provide me with feedback, bug fixes and enhancements for the stuff I am posting here on the SPS Weblog. I want you all to know that collaboration, help, feedback, and/or ideas are not only welcomed and appreciated, but are exactly the reason why I post these entries. I don't want fame or your money... I just want to see the Visual FoxPro Community improve the state of Visual FoxPro and the overall experience for developers that are working in it or companies that may be considering it as a viable option. It is my belief that one of the greatest data-centric development tools ever created deserves nothing less.

Here is the download link for the example project and vfpscrollbar.vcx source as well as a screen shot of the example that shows the scrollbars being used in the scrollable container class.

Download VFP Scrollbars Example and Source (46 KB approx.)

Saturday, August 27, 2005 7:19:31 AM (GMT Daylight Time, UTC+01:00)  #    Comments [12]
Saturday, August 27, 2005 2:20:12 PM (GMT Daylight Time, UTC+01:00)
Nice as always Craig. I know that this is still an unfinished control, but here is some feedback:

1) The lower right corner (bordered by the scrollbars and the form's edges) seems to "bleed" thru, i.e. it appears to be "transparent". By design?

2) The mouse wheel does not scroll the content.

3) Can the scrollbars disappear when not required? For example, if I maximize the form and all content is fully displayed, how about hiding the scrollbars.

4) Scrolling seems a bit sluggish.

If you could address these issues and put the finishing touches on this control, I think that MS should learn from it and incorporate it (or one like it) into Sedna. This goes double for your splitter control too!

Keep up your great contributions to the VFP world. !!! THE FOX ROCKS !!!
Mike
Sunday, August 28, 2005 12:07:48 PM (GMT Daylight Time, UTC+01:00)
Hi Mike,

>>1) The lower right corner (bordered by the scrollbars and the form's edges) seems to "bleed" thru, i.e. it appears to be "transparent". By design?

Yes and no. The scrollable container was a just a quick example of something that the scrollbar classes would be useful for. Yes, I could have added a gribber or simple grey shape at the bottom right of the scrollable container, but there is an issue with the XP themed controls and painting that the Fox Team needs to fix in Visual FoxPro. You'd also see a slight flicker on the gripper/shape at times.

To illustrate the problem with the XP themed controls, scroll the container around until you have the pageframe showing in the container and the tabs are half underneath the non-scrollable region above (where it says "Visual FoxPro Rocks!"). Then hover over the bottom half of the tabs that are visible and you will see that it paints right over the top of everything and does not respect the container's border.

There are other examples of this... animated gifs will sometimes show this behavior too. You can also position the pageframe so it has a tab directly behind one of the scrollbars and hover the mouse over the tab again... or try placing a sorting arrow over a themed header in a grid sometime. Basically these themed controls paint over anything else when they are doing their fancy themed hot tracking. The Fox Team will hopefully fix this in SP1.

>>2) The mouse wheel does not scroll the content.
Good point. I'll work on this unless you have some code that will make the vertical scrollbar respond to the mouse wheel events.

>>3) Can the scrollbars disappear when not required? For example, if I maximize the form and all content is fully displayed, how about hiding the scrollbars.
Yes, I haven't gotten the thumb/scroll box proportional code right yet. This will definitely be in one of the very next versions of this.

>>4) Scrolling seems a bit sluggish.
I haven't seen this at all, they scroll as fast as I can push the mouse or click. Is anyone else seeing this? Also, Mike can you run out a coverage profile log while you are using the scrollbars and they seem sluggish, then either send it to me or alert me to where the bottleneck is at your end. This would help a lot in solving this problem. Thanks.

Four really good points, and they are very much appreciated Mike. Thanks.
Monday, August 29, 2005 9:41:42 AM (GMT Daylight Time, UTC+01:00)
Amazing Work Craig!

Thank you once again!
Thursday, November 24, 2005 11:17:54 PM (GMT Standard Time, UTC+00:00)
Craig, that was incredible, especially to design and complete within 5 hours, I love it!!! It sure provided me with a fabulous solution!

Thank you so much!
Monday, December 05, 2005 11:01:05 PM (GMT Standard Time, UTC+00:00)
Thanks Craig !!

You can find the Spanish version of this article at (Puede encontrar la versión en Español de este artículo en:)

http://www.portalfox.com/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=100

Regards / Saludos,

Ana
www.amby.net
www.PortalFox.com
Sunday, April 30, 2006 6:38:39 AM (GMT Daylight Time, UTC+01:00)
You can also position the pageframe so it has a tab directly behind one of the scrollbars and hover the mouse over the tab again...

Has the solution for this been found?

Also with regard to the "SKUGGISH" behaviour...

This only appears in the VFP IDE when the form is NON MODAL. If the form is MODAL then this is not seen.

This is not apparent in an EXE created whether the form is modal or not.

The Controld bleeding through the container especially the Oage Frame tab is the main reason I cannot use this control.
Bernard Bout
Wednesday, September 26, 2007 9:42:36 PM (GMT Daylight Time, UTC+01:00)
Hi Craig,

Have you updated this control yet? I didn't see any references to an update.

In particular, I was looking for the update which eliminated the scrollbars, if they weren't necessary.

I really like this control, and with this addition, it would be even better!

Thanks Craig. You're a genius!!!

-Jim
JIM CAMPISI
Sunday, October 14, 2007 7:45:26 PM (GMT Daylight Time, UTC+01:00)
Craig,

I love this class...
I have only 1 problem with it - everytime when I modify form which contain this class and then I try to build my project I'm getting "File vfpscrollbar.vcx is in use and can not be recompiled". I have to close VFP and build again.

Any solution for that ?

Thank you for great class !
Adam
Sunday, November 04, 2007 1:02:47 PM (GMT Standard Time, UTC+00:00)
Adam, I've seen this before when a class is dropped on a form. In certain cases (I have yet to identify exactly what those cases are), you will get this compile error when recompiling all files (with option "re-compile all files" in the Build Options checked). I have also seen this before when a project hook is mistakenly added to the current project being built.

Because of this, when I "re-compile all files", I always issue a CLEAR ALL in the command window first.
Wednesday, November 14, 2007 9:16:31 AM (GMT Standard Time, UTC+00:00)
Hi Craig,

This is a really useful bit of work. Well done.

Have you managed to overcome any of the issues mentioned elsewhere in this thread?

There are three issues in particular: the option to respect the user's themes settings (colors, etc); the ability for the scrollbars to disappear when not required; and the ability to respond to the mouse wheel.

If ever you find the time to do any more work on this, it would be excellent. In the meantime, I might try to fix the above issues myself, but I don't have a fraction of your skills and wouldn't do such a good job on it as you would.

Mike Lewis
Thursday, January 31, 2008 11:11:30 AM (GMT Standard Time, UTC+00:00)
Dear Mr. Craig Boyd,

I wonder if you could help me.
I like to identify the thumb on the scrollbars.
I tried to use the control collection class ( Control.ControlCollection ), which is scrollbars member, unfortunately, it is appeared as one part (scrollbars + thumb).
With this in mind, I used the Scrollbars class which identified by studio.
Is there any way to isolate the thumb on the scrollbars & use it as arbitrary control?
If yes, I would be grateful if you would tell me how.

Many thanks in advance,
Miri (miridavidian@gmail.com)
PS: I like your answers very much.
Monday, April 21, 2008 6:46:27 AM (GMT Daylight Time, UTC+01:00)
still no update with this class? This one has a great potential and will help lots of vfp dev guys do their stuff much exciting.

how come there is no update yet?
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910