MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / ControlSetSliderOptions

Method ControlSetSliderOptions

source/script_gui.cpp:9681–9730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9679
9680
9681void GuiType::ControlSetSliderOptions(GuiControlType &aControl, GuiControlOptionsType &aOpt)
9682// Caller has ensured that aControl.type is slider.
9683{
9684 if (aOpt.range_changed)
9685 {
9686 // Don't use TBM_SETRANGE because then only 16-bit values are supported:
9687 SendMessage(aControl.hwnd, TBM_SETRANGEMIN, FALSE, aOpt.range_min); // No redraw
9688 SendMessage(aControl.hwnd, TBM_SETRANGEMAX, TRUE, aOpt.range_max); // Redraw.
9689 }
9690 if (aOpt.tick_interval_changed)
9691 {
9692 if (aOpt.tick_interval < 0) // This is the signal to remove the existing tickmarks.
9693 SendMessage(aControl.hwnd, TBM_CLEARTICS, TRUE, 0);
9694 else if (aOpt.tick_interval_specified)
9695 SendMessage(aControl.hwnd, TBM_SETTICFREQ, aOpt.tick_interval, 0);
9696 else
9697 // +TickInterval without a value. TBS_AUTOTICKS was added, but doesn't take effect
9698 // until TBM_SETRANGE' or TBM_SETTICFREQ is sent. Since the script might have already
9699 // set an interval and there's no TBM_GETTICFREQ, use TBM_SETRANGEMAX to set the ticks.
9700 if (!aOpt.range_changed) // TBM_SETRANGEMAX wasn't already sent.
9701 {
9702 SendMessage(aControl.hwnd, TBM_SETRANGEMAX, TRUE
9703 , SendMessage(aControl.hwnd, TBM_GETRANGEMAX, 0, 0));
9704 }
9705 }
9706 if (aOpt.line_size > 0) // Removal is not supported, so only positive values are considered.
9707 SendMessage(aControl.hwnd, TBM_SETLINESIZE, 0, aOpt.line_size);
9708 if (aOpt.page_size > 0) // Removal is not supported, so only positive values are considered.
9709 SendMessage(aControl.hwnd, TBM_SETPAGESIZE, 0, aOpt.page_size);
9710 if (aOpt.thickness > 0)
9711 SendMessage(aControl.hwnd, TBM_SETTHUMBLENGTH, aOpt.thickness, 0);
9712 if (aOpt.tip_side)
9713 SendMessage(aControl.hwnd, TBM_SETTIPSIDE, aOpt.tip_side - 1, 0); // -1 to convert back to zero base.
9714
9715 // Buddy positioning is left primitive and automatic even when auto-position of this slider
9716 // or the controls that come after it is in effect. This is because buddy controls seem too
9717 // rarely used (due to their lack of positioning options), which is the reason why extra code
9718 // isn't added here and in "GuiControl Move" to treat the buddies as part of the control rect
9719 // (i.e. as an entire unit), nor any code for auto-positioning the entire unit when the control
9720 // is created. If such code were added, it would require even more code if the slider itself
9721 // has an automatic position, because the positions of its buddies would have to be recorded,
9722 // then after they are set as buddies (which moves them) the slider is moved up or left to the
9723 // position where its buddies used to be. Otherwise, there would be a gap left during
9724 // auto-layout.
9725 // For these, removal is not supported, only changing, since removal seems too rarely needed:
9726 if (aOpt.buddy1)
9727 SendMessage(aControl.hwnd, TBM_SETBUDDY, TRUE, (LPARAM)aOpt.buddy1->hwnd); // Left/top
9728 if (aOpt.buddy2)
9729 SendMessage(aControl.hwnd, TBM_SETBUDDY, FALSE, (LPARAM)aOpt.buddy2->hwnd); // Right/bottom
9730}
9731
9732
9733

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected