Comunidad Gambas-es
Pseudo-Slider con tres indicadores - Versión para impresión

+- Comunidad Gambas-es (https://gambas-es.org)
+-- Foro: Gambas (https://gambas-es.org/forum-3.html)
+--- Foro: Aplicaciones/Fragmentos de Código (https://gambas-es.org/forum-8.html)
+--- Tema: Pseudo-Slider con tres indicadores (/thread-1713.html)



Pseudo-Slider con tres indicadores - vuott - 27-06-2024

Hola,
aquí un posible código para la realización de un Confused pseudo-Slider con tres indicadores de valor:

Código:
Private DrawingArea1 As DrawingArea
Private bt1 As Button
Private bt2 As Button
Private bt3 As Button
 
 
Public Sub Form_Open()
 
 With DrawingArea1 = New DrawingArea(Me) As "DrawingArea1"
   .X = 20
   .Y = 20
   .W = 310
   .H = 20
   .Border = Border.Solid
 End With
 
 With bt1 = New Button(DrawingArea1) As "BT"
   If Not Even(DrawingArea1.W * 0.03) Then .W = (DrawingArea1.W * 0.03) + 1
   .H = DrawingArea1.H
   .X = 0
   .Y = 0
   .Text = String.Chr(&2193)
 End With
 With bt2 = New Button(DrawingArea1) As "BT"
   .W = bt1.W
   .H = DrawingArea1.H
   .X = DrawingArea1.W - (DrawingArea1.W / 2)
   .Y = 0
   .Text = String.Chr(&2193)
 End With
 With bt3 = New Button(DrawingArea1) As "BT"
   .W = bt1.W
   .H = DrawingArea1.H
   .X = DrawingArea1.W - .W
   .Y = 0
   .Text = String.Chr(&2193)
 End With
 Me.Title = "Min = " & CStr(bt1.X) & "   Med =" & CStr(bt2.X) & "   Max =" & CStr(bt3.X)
 
End
 
Public Sub DrawingArea1_Draw()
 
 With Paint
   .Brush = Paint.Color(Color.Green)
   .Rectangle(bt1.X + bt1.W, 0, (DrawingArea1.W - bt1.X) - (DrawingArea1.W - bt2.X), DrawingArea1.H)
   .Fill
   .Brush = Paint.Color(Color.Orange)
   .Rectangle(bt2.X + bt2.W, 0, (DrawingArea1.W - bt2.X) - (DrawingArea1.W - bt3.X), DrawingArea1.H)
   .Fill
   .End
 End With
  
End
 
Public Sub BT_MouseMove()
 
 With Last
   .X = .X + Mouse.X - Mouse.StartX
   .Y = .Y + Mouse.Y - Mouse.StartY
 End With
 
 If Last.Y <> 0 Then Last.Y = 0
  
 Select Case Last.Id
   Case bt1.Id
     If bt1.X < 0 Then bt1.X = 0
     If bt1.X > bt2.X - bt1.W Then bt1.X = bt2.X - bt1.W
   Case bt2.Id
     If bt2.X < (bt1.X + bt1.W) Then bt2.X = bt1.X + bt1.W
     If (bt2.X + bt2.W) > bt3.X Then bt2.X = bt3.X - bt2.W
   Case bt3.Id
     If bt3.X < (bt2.X + bt2.W) Then bt3.X = bt2.X + bt2.W
     If (bt3.X + bt3.W) > DrawingArea1.W Then bt3.X = DrawingArea1.W - bt3.W
 End Select
 
 DrawingArea1.Refresh

 Me.Title = "Min = " & CStr(bt1.X) & "   Med = " & CStr(bt2.X) & "   Max = " & CStr(bt3.X)
 
End
Europaei sumus !


RE: Pseudo-Slider con tres indicadores - tincho - 27-06-2024

[Imagen: VJOi2iG.png]