Page 1 of 1

Special TrackBar Gadget [Windows]

Posted: Thu Oct 11, 2018 2:52 am
by RASHAD
The title said it all

Code: Select all

  #TBS_TOOLTIPS = $100
  
  If OpenWindow(0, 0, 0, 320, 450, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget    (3, 10,  20, 250, 20,"TrackBar Standard", #PB_Text_Center)
    TrackBarGadget(0, 10,  40, 300,50, 0, 24,#PB_TrackBar_Ticks|#TBS_TOOLTIPS |#TBS_FIXEDLENGTH )
    SetGadgetState(0, 12)
    SendMessage_(GadgetID(0), #TBM_SETTHUMBLENGTH,25,0)
    SendMessage_(GadgetID(0), #TBM_SETPAGESIZE ,0,1)
    ticn0 = SendMessage_(GadgetID(0), #TBM_GETRANGEMAX ,0,0)
    SendMessage_(GadgetID(0), #TBM_GETCHANNELRECT,0,r.RECT)
    ts0 = (r\right - r\left)/ticn0
    
    TrackBarGadget(1, 10,  100, 50,300, 0, 30,#PB_TrackBar_Ticks|#TBS_TOOLTIPS |#TBS_FIXEDLENGTH | #PB_TrackBar_Vertical|199726)
    SetGadgetState(1, 15)
    SendMessage_(GadgetID(1), #TBM_SETTHUMBLENGTH,25,0)
    SendMessage_(GadgetID(1), #TBM_SETPAGESIZE ,0,1)
    ticn1 = SendMessage_(GadgetID(1), #TBM_GETRANGEMAX ,0,0)
    SendMessage_(GadgetID(1), #TBM_GETCHANNELRECT,0,r.RECT)
    ts1 = (r\right - r\left)/ticn1
    
 Repeat
    Select WaitWindowEvent()
      
      Case #PB_Event_CloseWindow
        Quit = 1        
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0
            If  GetAsyncKeyState_(#VK_LBUTTON)
               GetCursorPos_ (@p.POINT) 
               ScreenToClient_ (GadgetID(0), @p)
               SetGadgetState(0, (p\x-ts0)/ts0)
            EndIf
            
          Case 1
            If  GetAsyncKeyState_(#VK_LBUTTON)
              GetCursorPos_ (@p.POINT) 
              ScreenToClient_ (GadgetID(1), @p)
              SetGadgetState(1, (GadgetHeight(1)-p\y-ts1 )/ts1)
            EndIf
        EndSelect
        
              

  EndSelect    
 Until Quit = 1
  EndIf


Re: Special TrackBar Gadget [Windows]

Posted: Thu Oct 11, 2018 12:10 pm
by Dude
Nice code, thanks! :)

Re: Special TrackBar Gadget [Windows]

Posted: Thu Oct 11, 2018 2:27 pm
by ebs
Rashad,

I like it!

Can you tell me what the magic number 199726 represents?
It doesn't seem to be any combination of the #TBS_ trackbar values.

Regards,
Eric