Silverfrost Forums

Welcome to our forums

SLider control %sl

27 Nov 2017 1:03 #20868

I remember seeing a slider control as an example in Clearwin using a moving icon in a graphics area, although I can’t find it now. It put me off using one. Now and for a long time, there appears to be a real slider control, %sl. For reference I have looked at the descriptions in FTN95.CFM and CWPLUS.ENH.

Such a slider control is sized in character cells, and returns a position (if moved by the mouse) relative to 1 pixel, which is likely to be an irrational number and different on different computers (using different windows versions, fonts and dpi settings, because they affect the character cell size in pixels). Moving the slider by means of the arrow keys has a step equal to 10% of the range defined with %sl. It also has the behaviour that if the slider is moved to a different start position with the mouse, the arrow step remains the same, but the start position is moved, so in a range 0 to 10, moving the slider by arrow from 1.67 set by mouse will give 2.67, 3.67 etc until the end is reached, whereupon the counting is reset. All very logical, but different to controlling the slider by mouse.

The position is returned as a REAL*8 number.

I see that the MSDN slider control is rather more sophisticated than the Clearwin+ one, i.e. has more options than just horizontal or vertical, and as (to quote) ‘Clearwin+ is just a wrapper for MS controls’, it does seem to me that the step should be the same with arrow keys as with the mouse, or be user-definable akin to the spin wheel, have the ability to select a range, to display tick marks, and jump to tick intervals etc.

%sl is quite friendly, but not very capable, as it stands.

Eddie

27 Nov 2017 2:51 #20871

Eddie

I don't have the details to hand but %sl has an undocumented option (probably [ms_style]) that takes integer arguments and accesses the Microsoft slider control, otherwise you get a native Clearwin+ slider.

27 Nov 2017 4:43 #20873

That's interesting. With ms_style, the slider has a different appearance, the position and limits have to be INTEGER. The arrow step is 1, and the mouse step also 1, if you can control the pointer that accurately.

Suppose you have a WRITE for the position in a callback, then holding an arrow key down gives a stream of incrementing/decrementing numbers. With single presses of the arrow key, the position is displayed twice, suggesting the callback happens twice, and even more but not consistently when moving with the mouse.

      OPTIONS (INTL, DREAL)
      WINAPP
      PROGRAM SLIDER
      INCLUDE <WINDOWS.INS>
      COMMON POSITION, iPOSITION
      INTEGER, EXTERNAL :: SLIDER_FN
!      POSITION = 0.0D0
      iPOSITION = 0
      IA = WINIO@('%ca[Slider demo]&')
!      IA = WINIO@('%30^sl[ms_style]', POSITION, 0.0D0, 1.5D0, SLIDER_FN)
      IA = WINIO@('%30^sl[ms_style]', iPOSITION, 0, 200, SLIDER_FN)
      END
      INTEGER FUNCTION SLIDER_FN()
      INCLUDE <WINDOWS.INS>
      COMMON POSITION, iPOSITION
!      WRITE(*,*) POSITION
      WRITE(*,*) iPOSITION
      SLIDER_FN = 1
      RETURN
      END
27 Nov 2017 11:00 #20878

Eddie

Maybe your caalback should return the value 2, otherwise you could get feedback.

28 Nov 2017 10:23 #20885

With a return value of 2, the behaviour is consistent, giving me a triple last position display, oddly with the last two on the same line in the character display window.

On the grounds that a slider is a parameter setting control, not a command control, this repetition probably doesn't matter. The callback is only there to display the position, and in some applications isn't needed anyway.

Eddie

29 Nov 2017 10:46 #20896

By the way, are there any more handy undocumented features?

E

30 Nov 2017 6:44 #20899

Some things are coming to light as a result of the development of Visual ClearWin+ and I plan to include these in the documentation in due course.

Please login to reply.