ANN: TrackBar control

TrackBar control

Overview

Modern Windows applications use cute TrackBar control, below is a screenshot from “Photos” application:

I decided to mimic this control in Clarion.

Screenshot1
Screenshot2

Features

The control supports both horizontal and vertical orientations, each orientation supports top/left, center and bottom/right alignments.

Demo app

The code is quite primitive:

  PROGRAM
  INCLUDE('trackbar.inc'), ONCE
  MAP
    INCLUDE('printf.inc'), ONCE
  END

Window                        WINDOW('Trackbar demo'),AT(,,260,100),CENTER,GRAY,SYSTEM,FONT('Segoe UI',9)
                                REGION,AT(16,26,186,22),USE(?rgnQuality)
                                PROMPT('Prompt1'),AT(16,14),USE(?lblQuality)
                                BUTTON('Close'),AT(197,76,47),USE(?btnClose),STD(STD:Close)
                              END

tbQuality                     CLASS(TTrackBar)
OnNewSelection                  PROCEDURE(LONG pValue), DERIVED, PROTECTED
                              END
  CODE
  OPEN(Window)
  
  tbQuality.Init(?rgnQuality)
  tbQuality.SetRange(10, 100)
  tbQuality.SetValue(50)
  
  ACCEPT
  END
  
tbQuality.OnNewSelection      PROCEDURE(LONG pValue)
sQuality                        STRING(6), AUTO
  CODE
  IF pValue < 50
    sQuality = 'Low'
  ELSIF pValue < 80
    sQuality = 'Medium'
  ELSE
    sQuality = 'High'
  END
  ?lblQuality{PROP:Text} = printf('Quality: %i%% (%s)', pValue, sQuality)

Requirements

  • Clarion versions: C6.3 and higher.
  • Template chains: ABC, Clarion.
  • Multi dll apps supported.

Home page

2 Likes

Clarion’s SLIDER controls are over-classed Windows trackbars. The RTL passes paint request to Windows, just handles possible transparency. I guess, if to use the manifest for a program, SLIDERs’ view have to match trackbars drawn using visual styles for current Windows version.

  • keyboard is supported (arrow keys, home key, end key).
  • TAB control order is supported.
  • 2 types of step values are supported: a step and a small step. When SHIFT key is pressed, arrow keys and mouse wheel change the value by a small step.