[Windows only] set In Out in TrackBar

Share your advanced PureBasic knowledge/code with the community.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 634
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

[Windows only] set In Out in TrackBar

Post by minimy »

This post was deleted. No how, when, or why. Nor do I find my beer. :shock:
But seriously .. Do not know how it happened but it is not. So I put it back.
I hope will be helpful.
(thank, motivates share) :wink:

Code: Select all

; minimy
; ==================


In=0
Out=100

  Window_0 = OpenWindow(#PB_Any, 450, 200, 450, 80, "SET IN-OUT", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
  If Window_0
    TrackBar_0 = TrackBarGadget(#PB_Any, 5, 5, 440, 50, In, Out, #PB_TrackBar_Ticks)
    Button_1 = ButtonGadget(#PB_Any, 5, 55, 90, 20, "IN")
    Button_2 = ButtonGadget(#PB_Any, 355, 55, 90, 20, "OUT")
    Texo = TextGadget(#PB_Any, 190, 55, 80, 20, "0",#PB_Text_Center)
    SetWindowLongPtr_(GadgetID(Trackbar_0),#GWL_STYLE,GetWindowLongPtr_(GadgetID(Trackbar_0),#GWL_STYLE) | #TBS_ENABLESELRANGE | #TBS_BOTH )
    SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELSTART,0,In);In
    SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELEND,0,Out);Out
    For a=0 To 100 Step 10
      SendMessage_(GadgetID(Trackbar_0),#TBM_SETTIC,0,a)
    Next
    SetWindowLongPtr_(GadgetID(Trackbar_0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(Trackbar_0), #GWL_EXSTYLE)); | #WS_EX_LAYOUTRTL );Al reves, de derecha a izquierda
    EndIf

Repeat
  Event = WaitWindowEvent(1)
  Select Event
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType   = EventType()
      If EventGadget = TrackBar_0
          SetGadgetText(Texo,Str(GetGadgetState(TrackBar_0)))
      ElseIf EventGadget = Button_1
        in=GetGadgetState(TrackBar_0)
        If in>out:kk=out:Out=in:In=kk:EndIf
          SendMessage_(GadgetID(Trackbar_0),#WM_SETREDRAW,#False,0)
          SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELSTART,0,In)
          SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELEND,0,Out)
          SendMessage_(GadgetID(Trackbar_0),#WM_SETREDRAW,#True,0)
          RedrawWindow_(GadgetID(Trackbar_0),#Null,#Null,#RDW_INVALIDATE) 
      ElseIf EventGadget = Button_2
        Out=GetGadgetState(TrackBar_0)
        If in>out:kk=out:Out=in:In=kk:EndIf
          SendMessage_(GadgetID(Trackbar_0),#WM_SETREDRAW,#False,0)
          SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELSTART,0,In)
          SendMessage_(GadgetID(Trackbar_0),#TBM_SETSELEND,0,Out)
          SendMessage_(GadgetID(Trackbar_0),#WM_SETREDRAW,#True,0)
          RedrawWindow_(GadgetID(Trackbar_0),#Null,#Null,#RDW_INVALIDATE) 
      EndIf
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = Window_0
        CloseWindow(Window_0)
        Window_0 = 0
        Break
      EndIf
  EndSelect
ForEver
Last edited by minimy on Sat Mar 04, 2017 8:13 pm, edited 2 times in total.
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: set In Out in TrackBar

Post by Kwai chang caine »

Cool !! Again a new gadget useful for the user of this forum
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
minimy
Enthusiast
Enthusiast
Posts: 634
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: set In Out in TrackBar

Post by minimy »

Kwaï chang caïne wrote:Cool !! Again a new gadget useful for the user of this forum
Thanks for sharing 8)
You wellcome friend! :wink:
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: set In Out in TrackBar

Post by netmaestro »

When a tip is specific to a single platform, it's best if the topic is named accordingly:

[Windows only] set In Out in TrackBar

Thanks for sharing!
BERESHEIT
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: set In Out in TrackBar

Post by luis »

netmaestro wrote:When a tip is specific to a single platform, it's best if the topic is named accordingly:
I would prefer a lot more if it was indicated the PB version it is supposed to be run on.
Inside the body of the post, not in the subject.
This is something a lot more difficult to decide by yourself (maybe 3 years later) than if the code is platform-specific or not IMHO.
Not that the two indications need to be mutually exclusive. :wink:
"Have you tried turning it off and on again ?"
User avatar
minimy
Enthusiast
Enthusiast
Posts: 634
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: [ONLY FOR WINDOWS] set In Out in TrackBar

Post by minimy »

Ok!, I'll remember ...
It is for Windows, not compatible with ZX Spectrum or Atari2600. :lol:
I like the music of Bowie ... :shock:
Thanks friends! :wink:
If translation=Error: reply="Sorry, Im Spanish": Endif
marc_256
Addict
Addict
Posts: 844
Joined: Thu May 06, 2010 10:16 am
Location: Belgium
Contact:

Re: set In Out in TrackBar

Post by marc_256 »

@ minimy

Cool, thanks for sharing ...

Marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
User avatar
minimy
Enthusiast
Enthusiast
Posts: 634
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: set In Out in TrackBar

Post by minimy »

marc_256 wrote:@ minimy

Cool, thanks for sharing ...

Marc
You wellcome friend!! :D
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply