ctl32_trackbar class
This visual class provides a trackbar control that can be used in VFP9. This class uses the Windows API to create a true Windows Common Controls trackbar, with full Themes compliance, just a couple of files to add to your project, No DLLs, no FLLs, no OCXs.
The following files should be added to your project, copy all the files to the same folder:
ctl32.h
ctl32.prg
ctl32.vct
ctl32.vcx
ctl32.prg
ctl32.vct
ctl32.vcx
The TrackBar control (also sometimes called a "slider" control) is used for navigating through a large amount of information or for visually adjusting a numeric setting. The TrackBar control has two parts: the thumb, also known as a slider, and the tick marks. The thumb is the part that can be adjusted. Its position corresponds to the ctlValue property. The tick marks are visual indicators that are spaced at regular intervals. The track bar moves in increments that you specify and can be aligned horizontally or vertically. An example use of a track bar would be for setting cursor blink rate or mouse speed.
The TrackBar is a scrollable control similar to the ScrollBar control. You can configure ranges through which the value of the ctlValue property of a track bar scrolls by setting the ctlMinimum property to specify the lower end of the range and the ctlMaximum property to specify the upper end of the range.
The ctlLargeChange property defines the increment to add or subtract from the ctlValue property when clicks occur on either side of the scroll box. The track bar can be displayed horizontally or vertically.
You can use this control to input numeric data obtained through the ctlValue property. You can display this numeric data in a control or use it in code.
The key properties of the TrackBar control are ctlValue, ctlTickFrequency, ctlMinimum, and ctlMaximum. ctlTickFrequency is the spacing of the ticks. ctlMinimum and ctlMaximum are the smallest and largest values that can be represented on the track bar.
Two other important properties are ctlSmallChange and ctlLargeChange. The value of the ctlSmallChange property is the number of positions the thumb moves in response to having the LEFT or RIGHT ARROW key pressed. The value of the ctlLargeChange property is the number of positions the thumb moves in response to having the PAGE UP or PAGE DOWN key pressed, or in response to mouse clicks on the track bar on either side of the thumb.
An interesting fact about this class is that trackbars inside a pageframe page look like they should, unlike trackbars in the .NET Framework, that don't have the page gradient background:
Trackbars in a VFP form:
Trackbars in a .NET form:
ctlAutoSize | Gets or sets a value indicating whether the height and/or width of the control is automatically sized. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
If set to TRUE, and depending on the control, the height and/or width will be adjusted to a default value.
ctlAutoSize = 0
ctlAutoSize = 1
Example:
See Also:
| ||||
ctlBackColor | Gets or sets the background color of the control. | |||
Value Type: Numeric
Default Value: -1
Read/Write: Yes.
Remarks:
Set to -1 to specify the default color, or set to ctlDefaultBackColor, or use the ctlResetBackColor method.
Example:
See Also:
| ||||
ctlBackgroundImage | Gets or sets the background image displayed in the control. | |||
Value Type:
Default Value:
Read/Write: Yes.
Remarks:
NOT IMPLEMENTED YET.
Example:
See Also:
| ||||
ctlBackgroundImageLayout | Gets or sets the background image layout. | |||
Value Type:
Default Value:
Read/Write: Yes.
Remarks:
NOT IMPLEMENTED YET.
Example:
See Also:
| ||||
ctlBackStyle | Specifies if the background of an object is transparent or opaque. | |||
Value Type: Numeric
Default Value: 1
Read/Write: Yes.
Remarks:
0: Transparent
1: Opaque
The trasparency only applies the background color of the parent object to the control.
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: -1
Read/Write: Yes.
Remarks:
Set to -1 to specify the default color, or set to ctlDefaultBorderColor, or use the ctlResetBorderColor method.
Example:
See Also:
| ||||
ctlBottom | Gets the distance, in pixels, between the bottom edge of the control and the top edge of its container's client area. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The value of this property is equal to the sum of the Top property value, and the Height property value.
Example:
See Also:
| ||||
ctlCanFocus | Specifies whether the control can receive focus. | |||
Value Type: Logical
Default Value: TRUE/FALSE
Read/Write: Yes.
Remarks:
The default value depends on the type of control.
Under normal circumstances, NEVER change the value of this property.
Example:
See Also:
| ||||
ctlControlSource | Specifies the source of data to which an object is bound. | |||
Value Type: Character
Default Value: NONE
Read/Write: Yes
Remarks:
Once the ControlSource property is set to a field or variable, the ctlValue property always has the same data value as the variable or field to which the ControlSource property is set.
Example:
See Also:
| ||||
ctlCreateControl | Forces the creation of the control, including the creation of the handle and any child controls. | |||
Remarks:
Under normal circumstances, there is no need to call this method.
Example:
See Also:
| ||||
ctlCreated | Gets a value indicating whether the control has been created. | |||
Value Type: Logical
Default Value: FALSE
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
ctlDefaultBackColor | Gets the default background color of the control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The default value depends on the type of control and the operating system version.
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The default value depends on the type of control and the operating system version.
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The default value depends on the type of control and the operating system version.
Example:
See Also:
| ||||
ctlDefaultHeight | Gets the default height of the control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The default value depends on the type of control and the operating system version.
Example:
See Also:
| ||||
ctlDefaultWidth | Gets the default width of the control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The default value depends on the type of control and the operating system version.
Example:
See Also:
| ||||
ctlDispose | Releases all resources used by the control. | |||
Remarks:
Under normal circumstances, there is no need to call this method, the class itself calls it from Destroy.
Example:
See Also:
| ||||
ctlEnabled | Gets or sets a value indicating whether the control can respond to user interaction. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
With the Enabled property, you can enable or disable controls at run time. For example, you can disable controls that do not apply to the current state of the application. You can also disable a control to restrict its use. For example, a button can be disabled to prevent the user from clicking it. If a control is disabled, it cannot be selected.
Example:
See Also:
| ||||
ctlFocused | Gets a value indicating whether the control has input focus. | |||
Value Type: Logical
Default Value: FALSE
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
Value Type: Logical
Default Value: FALSE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: 1
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Logical
Default Value: FALSE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Character
Default Value: "Default"
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: 0
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Logical
Default Value: FALSE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Logical
Default Value: FALSE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
Value Type: Numeric
Default Value: -1
Read/Write: Yes.
Remarks:
Set to -1 to specify the default color, or set to ctlDefaultForeColor, or use the ctlResetForeColor method.
Applies to non themed progress bars.
Example:
See Also:
| ||||
ctlHandle | Gets the window handle that the control is bound to. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The value is a Windows HWND.
Example:
See Also:
| ||||
ctlHide | Conceals the control from the user. | |||
Remarks:
Hiding the control is equivalent to setting the ctlVisible property to false. After the ctlHide method is called, the ctlVisible property returns a value of false until the ctlShow method is called.
Example:
See Also:
| ||||
ctlHostFormhWnd | Gets the window handle of the inner window of the parent form. | |||
Value Type: Numeric.
Default Value: 0
Read/Write: Read only.
Remarks:
The value is a Windows HWND.
Example:
See Also:
| ||||
ctlHosthWnd | Gets the windows handle of the parent object of this control, if there is one. | |||
Value Type: Numeric.
Default Value: 0
Read/Write: Read only.
Remarks:
The value is a Windows HWND.
Example:
See Also:
| ||||
ctlhWnd | DEPRECATED. Replaced by the .NET equivalent ctlHandle property. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
The value is a Windows HWND.
Example:
See Also:
| ||||
ctlIsHandleCreated | Gets a value indicating whether the control has a handle associated with it. | |||
Value Type: Logical
Default Value: FALSE
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
ctlLargeChange | Gets or sets a value to be added to or subtracted from the ctlValue property when the scroll box is moved a large distance. | |||
Value Type: Numeric
Default Value: 5
Read/Write: Yes.
Remarks:
When the user presses the PAGE UP or PAGE DOWN key or clicks the track bar on either side of the scroll box, the ctlValue property changes according to the value set in the ctlLargeChange property. You might consider setting the ctlLargeChange value to a percentage of the Height (for a vertically oriented track bar) or Width (for a horizontally oriented track bar) value. This keeps the distance your track bar moves proportionate to its size.
Example:
See Also:
| ||||
ctlLocationLeft | Gets the Left coordinate of the upper-left corner of the control relative to the upper-left corner of its container. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
ctlLocationTop | Gets the Top coordinate of the upper-left corner of the control relative to the upper-left corner of its container. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
ctlMaximum | Gets or sets the maximum value of the range of the control. | |||
Value Type: Numeric
Default Value: 10
Read/Write: Yes.
Remarks:
A value between -2147483648 and 2147483647 can be specified. (-0x7FFFFFFF to 0x7FFFFFFF, a 32 bit signed number.)
You can use the ctlSetRange method to set both the ctlMaximum and ctlMinimum properties at the same time.
Example:
See Also:
| ||||
ctlMinimum | Gets or sets the minimum value of the range of the control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Yes.
Remarks:
A value between -2147483648 and 2147483647 can be specified. (-0x7FFFFFFF to 0x7FFFFFFF, a 32 bit signed number.)
You can use the ctlSetRange method to set both the ctlMaximum and ctlMinimum properties at the same time.
Example:
See Also:
| ||||
ctlOrientation | Gets or sets a value indicating the horizontal or vertical orientation of the control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Yes.
Remarks:
0: Horizontal
1: Vertical
Example:
See Also:
| ||||
ctlRecreatingHandle | Gets a value indicating whether the control is currently re-creating its handle. | |||
Value Type: Logical
Default Value: FALSE
Read/Write: Read only.
Remarks:
Example:
See Also:
| ||||
ctlRefresh | Redraws the control. | |||
Remarks:
Example:
See Also:
| ||||
ctlResetBackColor | Resets the ctlBackColor property to its default value. | |||
Remarks:
The default value applied depends on the type of control and operating system version.
Example:
See Also:
| ||||
Remarks:
The default value applied depends on the type of control and operating system version.
Example:
See Also:
| ||||
Remarks:
The default values applied depend on the type of control and operating system version.
Example:
See Also:
| ||||
Remarks:
The default value applied depends on the type of control and operating system version.
Example:
See Also:
| ||||
ctlRight | Gets the distance, in pixels, between the right edge of the control and the left edge of its container's client area. | |||
Value Type:
Default Value:
Read/Write:
Remarks:
The value of this property is equal to the sum of the Left property value, and the Width property value.
Example:
See Also:
| ||||
ctlScroll | Occurs when either a mouse or keyboard action moves the scroll box. | |||
Remarks:
Example:
See Also:
| ||||
ctlSetRange | Sets the minimum and maximum values for a TrackBar. | |||
Remarks:
You can use this method to set the entire range for the TrackBar at the same time. To set the minimum or maximum values individually, use the Minimum and Maximum properties. If the minValue parameter is greater than the maxValue parameter, maxValue is set equal to minValue.
Example:
See Also:
| ||||
ctlShow | Displays the control to the user. Showing the control is equivalent to setting the ctlVisible property to TRUE. | |||
Remarks:
Example:
See Also:
| ||||
ctlShowFocusCues | Gets or sets a value indicating whether the control should display focus rectangles. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
ctlShowTicks | Specifies if the tick marks should be visible. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
ctlShowTips | Determines whether ToolTips are shown for the control. | |||
Value Type: Logical
Default Value: FALSE
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
ctlSmallChange | Gets or sets the value added to or subtracted from the Value property when the scroll box is moved a small distance. | |||
Value Type: Numeric
Default Value: 1
Read/Write: Yes.
Remarks:
When the user presses one of the arrow keys, the Value property changes according to the value set in the SmallChange property.
You might consider setting the value of SmallChange to a percentage of the value of the Height (for a vertically oriented track bar) or Width (for a horizontally oriented track bar) property. This sets the distance your track bar moves proportionate to its size.
Example:
See Also:
| ||||
ctlThemes | Specifies if themes are used for the control. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
The Themes property for visual classes can affect your existing user interface when using Microsoft Windows XP. You can turn this support off by setting the Themes property at the control, form, or _SCREEN system variable level.
Example:
See Also:
| ||||
ctlThumbSize | Gets or sets the size of the slider in a trackbar. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Yes.
Remarks:
Set to 0 to use the system default size.
Example:
See Also:
| ||||
ctlTickFrequency | Gets or sets a value that specifies the delta between ticks drawn on the control. | |||
Value Type: Numeric
Default Value: 1
Read/Write: Yes.
Remarks:
For a TrackBar with a large range of values between the Minimum and the Maximum properties, it might be impractical to draw all the ticks for values on the control. For example, if you have a control with a range of 100, passing in a value of 5 here causes the control to draw 20 ticks. In this case, each tick represents five units in the range of values.
Example:
See Also:
| ||||
ctlTickStyle | Gets or sets a value indicating how to display the tick marks on the track bar. | |||
Value Type: Numeric
Default Value: 2 (BottomRight)
Read/Write: Yes.
Remarks:
You can use the TickStyle property to modify the manner in which the tick marks are displayed on the track bar.
0: None. No tick marks appear in the control.
1: TopLeft. Tick marks are located on the top of a horizontal control or on the left of a vertical control.
2: BottomRight. Tick marks are located on the bottom of a horizontal control or on the right side of a vertical control.
3: Both. Tick marks are located on both sides of the control.
Example:
See Also:
| ||||
ctlToolTipPosition | Specifies the position of the ToolTip control used by a trackbar control. | |||
Value Type: Numeric
Default Value: 0
Read/Write: Yes.
Remarks:
0: TOP
1: LEFT
2: BOTTOM
3: RIGHT
Example:
See Also:
| ||||
ctlValue | Gets or sets the current value or state of the control. | |||
Value Type:
Default Value:
Read/Write: Yes.
Remarks:
Example:
See Also:
| ||||
ctlValueChanged | Occurs when the ctlValue property changes. | |||
Remarks:
Example:
See Also:
| ||||
ctlVisible | Gets or sets a value indicating whether the control is displayed. | |||
Value Type: Logical
Default Value: TRUE
Read/Write: Yes.
Remarks:
Example:
See Also:
|
No comments:
Post a Comment