remove ScrollBarGadget() maxvalue=10000 restriction

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

remove ScrollBarGadget() maxvalue=10000 restriction

Post by Keya »

I've just tested on all three OS and all three have no problems with a ScrollBar at 100,000,000.
Fortunately we can use SetGadgetAttribute(#Scrollbar, #PB_ScrollBar_Maximum, anyvalue) for this,
but in the Form Designer it imposes an unnecessary restriction of 10,000 and requires that extra call after its annoyed you with its "No you cant do that" message

Code: Select all

Enumeration FormWindow
  #Dlg1
EndEnumeration

Enumeration FormGadget
  #Scrollbar
EndEnumeration

Declare Scrollbar(EventType)

Procedure OpenDlg1(x = 0, y = 0, width = 404, height = 188)
  OpenWindow(#Dlg1, x, y, width, height, "Scrollbar Maximum Value", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  ScrollBarGadget(#Scrollbar, 100, 76, 196, 24, 0, 100, 0)
EndProcedure

Procedure Dlg1_Events(event)
  Select event
    Case #PB_Event_CloseWindow
      ProcedureReturn #False

    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Scrollbar
          Scrollbar(EventType())          
      EndSelect
  EndSelect
  ProcedureReturn #True
EndProcedure


Procedure Scrollbar(evt)
  SetWindowTitle(#Dlg1, "Scrollbar @ " + Str(GetGadgetState(#Scrollbar)))
EndProcedure

OpenDlg1()
SetGadgetAttribute(#Scrollbar, #PB_ScrollBar_Maximum, 100000000)
Repeat
  Define event.i = WaitWindowEvent()
  Dlg1_Events(event)
Until event = #PB_Event_CloseWindow
End