Omitting TickInterval's value (slider option)

Report problems with documented functionality
User avatar
Ragnar
Posts: 239
Joined: 30 Sep 2013, 15:25

Omitting TickInterval's value (slider option)

13 Apr 2019, 07:14

Slider option TickInterval states:
After the word TickInterval, specify the interval at which to display additional tickmarks (if the interval is omitted, it is assumed to be 1).
Unless I'm mistaken, this means that TickInterval and TickInterval1 should do the same, but they don't. TickInterval resets the control to the default view, i.e. only display the tick marks at the starting and ending positions. TickInterval1 associates every increment in the range with a tick mark.

I assume that TickInterval is meant to behave like the TBM_SETTICFREQ message, which also states something similar:
The default setting for the frequency is one; that is, every increment in the range is associated with a tick mark.
just me
Posts: 6367
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Omitting TickInterval's value (slider option)

14 Apr 2019, 03:50

Interestingly, TickInterval (without an interval) works as described at control creation time if you additionally specify a range. If a range is specified you get the same result by adding the TBS_AUTOTICKS (0x0001) style:

Code: Select all

#NoEnv
Gui, Add, Slider, w400 Range0-100 TickInterval
Gui, Add, Slider, w400 Range0-100 +0x0001
Gui, Add, Slider, w400 +0x0001
Gui, Show, , Test
Return
GuiCLose:
ExitApp
The behaviour of the trackbar control (slider) might have been changed after the TickInterval option was implemented.
lexikos
Posts: 6397
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Omitting TickInterval's value (slider option)

07 May 2019, 06:19

It seems to be a peculiarity of the Trackbar control that the ticks are not added until you set the range or tick interval, even if you set either setting to the value it should already have.

Code: Select all

Gui, Add, Text,, No messages sent
Gui, Add, Slider, Section hwndh x150 yp w400 +0x1

Gui, Add, Text, xm, TBM_SETRANGEMAX
Gui, Add, Slider, hwndh xs yp w400 +0x1
SendMessage TBM_GETRANGEMAX:=0x402, 0, 0,, ahk_id %h%
SendMessage TBM_SETRANGEMAX:=0x408, true, ErrorLevel,, ahk_id %h%

Gui, Add, Text, xm, TBM_SETTICFREQ
Gui, Add, Slider, hwndh xs yp w400 +0x1
; "The default setting for the frequency is one"
SendMessage TBM_SETTICFREQ:=0x414, 1, 0,, ahk_id %h%

Gui, Show, , Test
Actually, the AutoIt documentation says this:
$TBS_AUTOTICKS - Adds tick marks when you set the range on the slider by using the TBM_SETRANGE message

Microsoft wrote:The logical units of a trackbar are the set of contiguous values that the trackbar can represent. They are usually defined by specifying the range of possible values with a TBM_SETRANGE message as soon as the trackbar has been created.
I suppose that Microsoft expected a TBM_SETRANGE message to be sent immediately, so there was no point in setting up the ticks before that even when TBS_AUTOTICKS is present. If it was a bug, I suppose they missed it because TBM_SETRANGE is usually sent.

Code: Select all

Gui, Add, Text,, Ticks can also be set manually
Gui, Add, Slider, hwndh w400 +0x1
Loop 10
    SendMessage TBM_SETTIC:=0x404, 0, A_Index,, ahk_id %h%

Gui, Add, Text,, and can be combined with TBM_SETTICFREQ
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 2, 0,, ahk_id %h%
Loop 10
    SendMessage TBM_SETTIC:=0x404, 0, A_Index,, ahk_id %h%

Gui, Add, Text,, but they're overwritten by TBM_SETTICFREQ
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 2, 0,, ahk_id %h%
Loop 10
    SendMessage TBM_SETTIC:=0x404, 0, A_Index,, ahk_id %h%
SendMessage TBM_SETTICFREQ:=0x414, 2, 0,, ahk_id %h%

Gui, Add, Text,, or even TBM_SETRANGEMAX
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 2, 0,, ahk_id %h%
Loop 10
    SendMessage TBM_SETTIC:=0x404, 0, A_Index,, ahk_id %h%
SendMessage TBM_SETRANGEMAX:=0x408, true, 100,, ahk_id %h%

Gui, Add, Text,, and they interact oddly (just a few marks in odd places)
Loop Parse, % "10,8,7,6,5,4", % ","
{
    Gui, Add, Slider, hwndh w400 +0x1
    SendMessage TBM_SETTICFREQ:=0x414, A_LoopField, 0,, ahk_id %h%
    Loop 10
        SendMessage TBM_SETTIC:=0x404, 0, A_Index,, ahk_id %h%
}

Gui, Show, , Test
My conclusion is that TBM_SETTICFREQ and TBM_SETRANGEMAX both do the equivalent of TBM_CLEARTICS followed by TBM_SETTIC at each interval, if TBS_AUTOTICKS is present. Testing with TBM_CLEARTICS and TBM_SETRANGEMAX shows that TBM_SETTICFREQ must store the interval, not just set the ticks:

Code: Select all

Gui, Add, Text,, Just set range max = 100
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETRANGEMAX:=0x408, true, 100,, ahk_id %h%

Gui, Add, Text,, Set interval = 10
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 10, 0,, ahk_id %h%

Gui, Add, Text,, TBM_CLEARTICS removes ticks
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 10, 0,, ahk_id %h%
SendMessage TBM_CLEARTICS:=0x409, true, 0,, ahk_id %h%

Gui, Add, Text,, TBM_SETRANGEMAX uses previously set interval
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 10, 0,, ahk_id %h%
SendMessage TBM_CLEARTICS:=0x409, true, 0,, ahk_id %h%
SendMessage TBM_SETRANGEMAX:=0x408, true, 100,, ahk_id %h%

Gui, Add, Text,, but TBM_SETTICFREQ 0 prevents autoticks
Gui, Add, Slider, hwndh w400 +0x1
SendMessage TBM_SETTICFREQ:=0x414, 10, 0,, ahk_id %h%
SendMessage TBM_SETTICFREQ:=0x414, 0, 0,, ahk_id %h%
SendMessage TBM_SETRANGEMAX:=0x408, true, 100,, ahk_id %h%

Gui, Show, , Test

As for the option, +TickInterval is implicitly interpreted as +TickInterval0. When the value is zero, TBM_SETTICFREQ is not sent, so all the option does is add the TBS_AUTOTICKS style. Adding the style has no immediate effect; it apparently only affects the behaviour of TBM_SETTICFREQ and TBM_SETRANGE.

I think that it would be more intuitive and useful for +TickInterval after creation to restore the ticks at the previously set interval rather than reset it to 1. It already does this, except that the change doesn't take effect until you set the range. If you want to reset it to 1, you only need to press one extra key.

To have it be applied immediately, all we need to do is set the range min or max to the value it already had, which can be retrieved via TBM_GETRANGE'. There is no TBM_GETTICFREQ message.

-TickInterval sends TBM_CLEARTICS, which I've shown only lasts until the range is reset (it would have to be done separately, since -TickInterval Range0-100 always sets the range first), but also removes the TBS_AUTOTICKS style. If you -TickInterval and then separately +0x1 +Range0-100, the ticks are restored at the previously set interval. By contrast, passing 0 to TBM_SETTICFREQ disables autoticks completely, until TBM_SETTICFREQ is sent with a non-zero value.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 4 guests