SliderControl Library
This is just a small library that makes SliderControls easier to control (pun not intended), with the following features:
-Set the position of a SliderControl (SliderControl_SetPosition)
-Get the position of a SliderControl (SliderControl_GetPosition)
-Trigger a custom event when the SliderControl is moved (On
WindowIdEvent_SliderPositionChanged)
Steps needed to use this library:
-Extract the attached zip to your script's folder
-Register your control with SliderControl_Register (You only need this if you are going to use the SliderPositionChanged event)
-Register the MessageNotification event with the SliderControl message handler (Again, only needed for the event, see example usage for more info)
-That's all folks, you're now ready to use this library!
Example Usage:
code:
/*----------
Example Usage of SliderControl
In this example the window is called SliderExample, and the SliderControl's Id is TestSlider.
----------*/
var SliderExample = MsgPlus.CreateWnd("Example.xml", "SliderExample");
/* This just registers a few details the library needs */
SliderControl_Register(SliderExample, "TestSlider");
/* This handles the messages for when the user moves your SliderControl */
/* If you already use MessageNotification for other messages, simply trigger the
SliderControl_MessageHandler function inside your existing MessageNotification, passing
all the same parameters, e.g:
function OnSliderExampleEvent_MessageNotification(PlusWnd, Message, wParam, lParam){
//Your other message handling stuff here
SliderControl_MessageHandler(PlusWnd, Message, wParam, lParam);
}
*/
var OnSliderExampleEvent_MessageNotification = SliderControl_MessageHandler;
/* This event is triggered when the Slider is moved by the user */
function OnSliderExampleEvent_SliderPositionChanged(PlusWnd, ControlId, Position){
Debug.Trace(PlusWnd.WindowId + "->" + ControlId + " is now at position " + Position);
}
/* This function sets the position of the specified SliderControl (duh) */
SliderControl_SetPosition(SliderExample, "TestSlider", 50);
/* And this function gets the current position of the specified SliderControl */
var Position = SliderControl_GetPosition(SliderExample, "TestSlider");
Known problems:
-Doesn't work for vertically oriented SliderControls, working on it. FIXED
What'cha waiting for? DOWNLOAD