Special TrackBar Gadget [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Special TrackBar Gadget [Windows]

Post 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

Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Special TrackBar Gadget [Windows]

Post by Dude »

Nice code, thanks! :)
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Re: Special TrackBar Gadget [Windows]

Post 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
Post Reply