SG_TrackBarGadget

Syntax:

Result=SG_TrackBarGadget(SG_GadgetID_L.l, X_Pos_L.l, Y_Pos_L.l, Width_L.l, Height_L.l, StartValue_L.l, EndValue_L.l, [Flags_L.l])

Parameters:

SG_GadgetID_L

=

The number of the gadget

X_Pos_L

=

the x-position of the gadget

Y_Pos_L

=

the y position of the gadget

Width_L

=

the width of the gadget

Height_L

=

the height of the gadget

StartValue_L

=

is the lowest value, the gadget can return

EndValue_L

=

is the highest value, the gadget can return

[Flags_L]

=

'Flags' are always optional and can be composed of one or several (using the bitwise OR operator '|') of the following constants:

#PB_TrackBar_Ticks : Display a 'tick' marker at each step.

=

#PB_TrackBar_Vertical : The trackbar is vertical (instead of horizontal which is the default).

=


Return Values:

Result

=

contains a pointer to the internal gadget structur. See the source of this lib for more information


Description:

Creates a TrackBar gadget in the current screen. It allows you to select a range of values with a slide bar, like ones found in several multimedia players. The Minimum-Maximum range should be between 0 and 10,000. SG_GadgetID_L will be the numeric identifier returned by SG_EventScreenGadgetID() command.

The following commands can be used to act on this gadget:

- GetGadgetState(): Returns the current cursor position (value between the Minimum-Maximum range).

- SetGadgetState(): Change the current cursor position.

- SetGadgetFlag(): Change the current Flag of the gadget


Example:

#TrackBar_0 = 0

If Not InitSprite() Or Not InitMouse() Or Not InitKeyboard()
  End
EndIf

If OpenWindow(1, 0, 0, 1024, 768, "Screen Gadget TrackBar", #PB_Window_BorderLess)
  If OpenWindowedScreen(WindowID(1), 0,0, 1024, 768, 0, 0, 0)
    ; create a mouse
    If CreateSprite(0, 8, 8) 
      If StartDrawing(SpriteOutput(0)) 
        Circle(4, 4, 4, RGB(255, 255, 255)) 
        StopDrawing()
      EndIf 
    EndIf
    
    SG_TrackBarGadget(#TrackBar_0, 700, 500, 200, 20, 1, 100)
    
    Repeat
      ClearScreen(0)
      SG_DrawGadgets()
      ExamineMouse() 
      DisplayTransparentSprite(0, MouseX(), MouseY())
      FlipBuffers()
      
      Event = SG_ScreenGadgetEvent() ; This line checks if an event happened and resolve the mouse actions with the gadgets
      GadgetID = SG_EventScreenGadgetID() ; Is it a gadget event?
      EventType = SG_EventType() ; The event type
      
      If Event = #PB_Event_Gadget And EventType = #SG_EventType_LeftRelease
        
        If GadgetID = #TrackBar_0
          Debug SG_GetGadgetState(#TrackBar_0)
        EndIf
      EndIf
      
      
      
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
  
  
EndIf

End

Remarks:



Supported OS:   Windows