Using a Slider

You can set the minimum and maximum values of a slider and its colour using the Property inspector. See the XML code at the bottom of the page for the properties that we set. Use the slider in the demonstration below to change the angle of the label.

Demonstration

If the demo does not work in your current browser, try another such as Chrome. If you see no display at school, the security system might have blocked it. You can try instead this direct link to the program running on its own page.

SliderDemo.html

Smart Pascal Code

unit Form1;

interface

uses 
  SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms, 
  SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Panel,
  SmartCL.Slider, SmartCL.Controls.Label;

type
  TForm1 = class(TW3Form)
    procedure W3Slider1Change(Sender: TObject);
  private
    {$I 'Form1:intf'}
  protected
    procedure InitializeObject; override;
  end;

implementation

procedure TForm1.W3Slider1Change(Sender: TObject);
begin
  var angle := W3Slider1.Value;
  W3Label1.Angle := angle;
  var intAngle := round(angle);
  W3Label1.Caption := 'Angle: ' + intToStr(intAngle);
end;

procedure TForm1.InitializeObject;
begin
  inherited;
  {$I 'Form1:impl'}
  W3Label1.Font.Size := 16;
end;

initialization
  Forms.RegisterForm({$I %FILE%}, TForm1);
end.

XML Code of Form

<SMART>
  <Form version="2" subversion="1">
    <Created>2014-11-06T20:53:22.659</Created>
    <Modified>2014-11-06T20:58:44.585</Modified>
    <object type="TW3Form">
      <Caption>W3Form</Caption>
      <Name>Form1</Name>
      <object type="TW3Panel">
        <Width>152</Width>
        <Top>8</Top>
        <Left>8</Left>
        <Height>112</Height>
        <Name>W3Panel1</Name>
        <object type="TW3Label">
          <Caption>Angle: 0.00</Caption>
          <Width>136</Width>
          <Top>32</Top>
          <Left>8</Left>
          <Height>40</Height>
          <Name>W3Label1</Name>
        </object>
      </object>
      <object type="TW3Slider">
        <Minimum>-30</Minimum>
        <Maximum>30</Maximum>
        <Width>152</Width>
        <Top>128</Top>
        <Left>8</Left>
        <Height>32</Height>
        <Color>32960</Color>
        <Name>W3Slider1</Name>
        <OnChange>W3Slider1Change</OnChange>
      </object>
    </object>
  </Form>
</SMART>

Programming - a skill for life!

How to use a range of visual components such as edit boxes, combo boxes, grids and charts on one or multiple forms (including a modal form)