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.