Working with ISlider Parts

The following tasks are associated with using an ISlider* part in visual composition. Tasks that are common to many parts are described in related topics.

Selecting PM compatibility
You can define either a native system slider or an OS/2 Presentation Manager (PM) slider. The two styles are functionally equivalent. To provide a PM-compatible slider, open the style property in the ISlider* property sheet and set the pmCompatible style to on.

Selecting the orientation
By default, the slider is horizontal. For a vertical slider, open the style property in the ISlider* property sheet. Then, set the vertical style to on and the horizontal style to off.

Defining a primary scale
To define a primary scale, specify the scale size and location.

Drawing a value scale
To display scale tick marks with value text, use custom logic. Open the pop-up menu of the composite part from the free-form surface and connect the ready event of the composite part to Custom logic for the ISlider* part. Enter C++ code to set the size and text for each tick mark you want to display.

For example, if you want the user to set a rating from 0 to 100 with a primary scale marked at intervals of 10 and a secondary scale marked at intervals of 5, you could enter the following code:

  int i;
  target->setPrimaryScale(IProgressIndicator::scale1);
  target->setTicks(IProgressIndicator::scale1, 101);
  for (i = 0; i < 101; i += 10)
  {
    target->setTickLength(i, 10);
    target->setTickText(i, IString(i));
  }
  target->setPrimaryScale(IProgressIndicator::scale2);
  target->setTicks(IProgressIndicator::scale2, 101);
  for (i = 0; i < 101; i += 5)
  {
    target->setTickLength(i, 5);
    target->setTickText(i, IString(i));
  }

Selecting the slider button location
To select the location of slider buttons relative to the slider shaft, open the style property in the ISlider* property sheet. To specify slider buttons, set one of the following styles to on and set the others to off.

If you do not want slider buttons, set all of these styles to off.

Setting the home position
To define the home position for the slider, set the homePosition property in the ISlider* property sheet. With the <default> property value, the home position is at the left end of a slider or at the bottom end of a vertical slider. Alternatively, select one of the following choices in the value column:

The location of the home position depends on the orientation of the slider and the home position value you specify:

Location of the home position

homeBottomLeft homeTopRight
Horizontal orientation Left end of the shaft Right end of the shaft
Vertical orientation Bottom end of the shaft Top end of the shaft

Setting the initial position
To initially position the arm somewhere other than at the home position, set either of the following properties in the ISlider* property sheet. Enter the property value in the value column.

armTickOffset
Number of value increments (ticks) from the home position

armPixelOffset
Number of pixels from the home position

Positioning to ticks
To force the arm to the nearest tick mark whenever it is moved, open the style property in the ISlider* property sheet and set the snapToTickMark style to on.

Getting the selected value
To provide the selected value to an attribute in another part or to an action parameter, connect the ISlider* armTickOffset attribute to the target attribute or parameter.


Related procedures
Common Tasks for Control Parts
Setting Part Style Properties
Setting Part Color Properties
Setting Part Font Properties
Setting Part Handlers Properties
Setting Part Framing Properties
Working with VisualAge User Interface Parts

Related references
ISlider
Property Settings -- ISlider
Portability -- ISlider