Home

News

Downloads

Forums

Notes

Readme

Links

Foro en Espaņol


ctl32_balloontip

ctl32_datepicker

ctl32_formstate

ctl32_ftp

ctl32_gripper

ctl32_monthcalendar

ctl32_progressbar

ctl32_scontainer

ctl32_statusbar

ctl32_trackbar


ctl32_scontainer: overview | members | pictures

By Carlos Alloatti and Malcolm Greene

Overview

This class provides a Scrollable Container control that can be used in VFP 9.

This class is not a replacement for a Grid! It may be viewed as a replacement for a Pageframe, where instead of having N pages one on top of the other, you have N pages one after the other, and you can only view one page at a time.

So, for the same reasons that you will not have a Pageframe with N pages as N records in a table, you should not have a ctl32_scontainer displaying N records from a table one after the other.

If you think that a Pageframe with N pages as records in a table is OK, please do not ask me how to achieve that with the ctl32_scontainer, I don't know.

It uses the Windows API to create true Windows common controls Scrollbars, full Themes compliance, just a couple of class files to add to your project, No DLLs, no FLLs, no OCXs.

This class uses BINDEVENT with the new features only available in VFP9. It will not work in previous versions of VFP. If you are using a previous version of VFP, you should really upgrade to take advantage of the many new features, and to support VFP.


Properties, Events & Methods

You can find a complete reference to all properties, events & methods of the class here.


Main Features

  • Visual design, drop control in a form, add a child control to it.
  • Supports mouse wheel vertical and horizontal scrolling, also mouse wheel zoom in/out in contained image control.
  • Supports click and drag scrolling.
  • Active control auto-scrolling, with configurable vertical and horizontal margin, when a control gets focus it scrolls into view.
  • Transparently participates in the form's normal tab order
  • Fully configurable behaviour: smallchange, largechange, wheelchange, always display scrollbars, display one, both or no scrollbars.
  • Scrollbars dissapear or get disabled when not needed.
  • Scroll boxes correctly report position and size of the visible area within the total contained control area.
  • Windows XP and Vista theme compliance.
  • Events and methods to implement your own scrolling controls.
  • Client control can be loaded dinamically using the class AddObject() or NewObject() methods.

Uses

  • Paning large images.
  • Create Explorer, Taskpane and other modern GUI interfaces.
  • Anywhere a general purpose container needs to scroll due to form or screen size.

Pictures

A scrollable container with a container control inside. You can tab thru the controls and get automatic scroll.


A scrollable container with an image control inside. You can zoom the image in/out with CTRL-MouseWheel.


Quick Start

If you want a ctl32_scontainer on a form, drag the ctl32_scontainer control from the Project Manager window and drop it into the Form.

How to add controls to the scrollable container:

Do not add multiple controls inside the scrollable container!

The scrollable container supports only one client control. Add a container or an image control.

For SIMPLE nested containers (or when working with an image control): make the scrollable container large, add a container with controls, or an image control, align it to the left and top of the scrollable container, then shrink the scrollable container to size.

For large or complex nested containers, create another container in a form, or as a class, and add your controls to that container. Then insert your container with controls into the scrollable container. If you used a Form, copy the container from that form, then control-click on the scrollable container and paste it. If you created a container class, control-click on the scrollable container, then drag and drop the container class from your project window (there are many other ways to do this)

Think of the scrollable container as a PageFrame that can have only one page, and of your own container as a Page. The hierarchy level for your controls will be the same as in a PageFrame-Page scenario.

The scrollable container will use the first control it contains, ignoring any other controls added to it, that is why is crucial that you use a container control, or just a single image control.

Using the PageFrame-Page analogy again, you can't also add controls directly to a PageFrame in VFP.


Videos

This is a quick flash video with no sound, to see how you can use the class.


Sample Project

See the sample project included in the Sample folder to see examples of how to use the control and what can be done.


BindEvent

This class does Bindevents to the following windows and window messages:

Thisform.HWnd, WM_KEYUP

Thisform.HWnd, WM_CAPTURECHANGED

Thisform.HWnd, WM_LBUTTONUP

If you hook to those same window/event pairs in some other part of your code, recall what the Help file says:

"When binding to Windows message (Win Msg) events, only one hWnd to Windows message pairing can exist."


Bugs

20060928

The sunken border will not display in versions of Windows previous to XP. This is due to a bug in the themes handling code in ctl32_SetTheme(). This is fixed in version 20061001


Known Problems

There is a bug in the way VFP draws the border of sunken frames when no theme is active:

This is the border of a VFP textbox.

This is the border of a VFP container, SpecialEffect set to Sunken. The colors of the border are mixed up.

At normal 100% view you can hardly notice, but I do! (Off Site Link)


There is a bug in VFP with PageFrames inside a Container control. Since the ctl32_scontainer is based on the VFP Container control class, it inherites this bug. The workaround is not to use a PageFrame control inside a ctl32_scontainer control. Anyway, the whole point of having a scrollable container is so you will not be forced to use a PageFrame when things don't fit in a form.

Page tabs of PageFrame control bleed thru when inside a Container

ActiveX components will have the same problems, they should not be used inside a scrollable container.


Change Log

2006XXXX

Now client controls can be added dinamically. Added code to AddObject() and NewObject() to remove actual client control when adding new object. Also added a BINDEVENT to EvtHandler_This_NewObject() This method is binded to AddObject and NewObject, and setups the environment for the new client control.

Changed the _ThemeStatus, _HostHWnd, _FormType functions in _util of ctl32_common. Eliminated all references to ThisForm, now the form is determined from the control that is passed as a parameter to this functions.

Changed the way _Util object is added to control, from newobject to addproperty, so it will not count as another control.

Added ctlVcxStructs and ctlVcxCommon, they specify the name/location of the ctl32_structs and ctl32_common classes.

Added a ctlZoom property that indicates the amount of zoom of the client image control. 100% is normal view.

The zoom routine has been changed to a nicer curve, from 0.1% to 3199.99% (maximum allowed by image control) The values are stored in ctl32_SetZoomLevels()

Still missing a decent routine for centering the image after zoom in/out

Set as hidden some methods that where public by mistake.

20061010

ctlOS() method removed, moved to _util of ctl32_common

Added ctlRestoreSize() method, restores image size to default size after size change by ctrl-mousewheel. Fired by double click on image.

20061001

Added ctlTheme() and ctlOS() methods. Bugs fixed.