Recent

Author Topic: HELP! Next and Previous buttons  (Read 3134 times)

DmedZ

  • New Member
  • *
  • Posts: 41
HELP! Next and Previous buttons
« on: October 02, 2015, 10:52:23 am »
Hi everyone

So I'm having a little issue trying to create custom next and previous buttons...what I mean by this is I'm trying to press 1 object (TButton, Timage...etc) and have it keep moving through files but I can't seem to wrap my head around how to do this.

I worked around it by making a bunch of buttons that represent the file that's about to be shown or played so if I have 3 movies (mov1, mov2, mov3) and wanted to go from mov1 to mov2 I created 3 buttons to do that so Tbutton1 pressed will go to mov2 then hide and show Tbutton2 pressed will go to mov3. Which is impractical coz if I have 500 files I can't create 500 Tbuttons.

derek.john.evans

  • Guest
Re: HELP! Next and Previous buttons
« Reply #1 on: October 02, 2015, 11:31:34 am »
Oooo, my. 500 buttons. Thats kinda funny  :D

Store the filenames in a control like a TListBox, TComboBox, TListView, etc.

Those controls have ItemIndex's or Selected properties. The 2 (prev/next) buttons simply adjust the item selected. (The code for which is different depending on the control chosen)

You can pick up the change using a OnChange event, which will copy the selected filename to your movie player control.

Should only be ~9 lines of code. You only have to write ~3-4 lines.


« Last Edit: October 02, 2015, 11:34:04 am by Geepster »

DmedZ

  • New Member
  • *
  • Posts: 41
Re: HELP! Next and Previous buttons
« Reply #2 on: October 02, 2015, 06:04:16 pm »
Apologies but that left me with more questions than answers

Coz i would also not only like to apply this method to opening files but to objects on the form as well
so for example in my program i have the "Slideshow" and i want to keep pressing the Button i have in place to keep going through the pictures (Timages) going back and forwards through the pictures and i dont think what you mentioned there would work in this instance.

I understand better in code so if anyone could assist me with a concept that can work with this idea i would be greatful  ;)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: HELP! Next and Previous buttons
« Reply #3 on: October 02, 2015, 06:38:03 pm »
First decide how you will store the data items you want to browse.
In an array, a TList, a TFPList, a linked list, an external database... or whatever.
Then write GetFirst() and GetNext() functions that return the data you want, based on the container you've chosen to use for their storage.
Hook up your ShowNext button's OnClick to a ShowNext(Sender: TObject); method that calls GetNext() and displays the data it receives.

 

TinyPortal © 2005-2018