Page 1 of 1

[Windows only] set In Out in TrackBar

Posted: Wed Sep 11, 2013 4:06 pm
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

Re: set In Out in TrackBar

Posted: Thu Sep 12, 2013 8:36 am
by Kwai chang caine
Cool !! Again a new gadget useful for the user of this forum
Thanks for sharing 8)

Re: set In Out in TrackBar

Posted: Thu Sep 12, 2013 10:59 am
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:

Re: set In Out in TrackBar

Posted: Thu Sep 12, 2013 4:50 pm
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!

Re: set In Out in TrackBar

Posted: Thu Sep 12, 2013 5:03 pm
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:

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

Posted: Thu Sep 12, 2013 11:34 pm
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:

Re: set In Out in TrackBar

Posted: Sat Sep 14, 2013 6:27 am
by marc_256
@ minimy

Cool, thanks for sharing ...

Marc

Re: set In Out in TrackBar

Posted: Sat Sep 14, 2013 1:32 pm
by minimy
marc_256 wrote:@ minimy

Cool, thanks for sharing ...

Marc
You wellcome friend!! :D