Get Results. Listicongadget()

Just starting out? Need help? Post your questions and find answers here.
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Get Results. Listicongadget()

Post by Bong-Mong »

can anyone take alook at these codes,
im trien to get results from iconlistgadget(), i can get a messagerequester() to work, but i did'nt write the code.
im trien to get selected file to play (.mp3/.wav)

i have a load button, with openfilerequester(), and file plays.
now i want; if file not loaded to play from listicongadget()
but im having trouble playing #Playlist results

Code: Select all

 Case #WM_DROPFILES
      *dropped = DropFiles ()
      num.l = DragQueryFile_ (*dropped , $FFFFFFFF, temp$, 0)

       f$=""
       For files = 0 To num - 1
        f$ + GetDropFile (*dropped, files) + Chr (13)
      Next
     AddGadgetItem(#Playlist, -1,f$ ,0 )
     f$ = GetGadgetItemText(#Playlist, 1, 0)
     MessageRequester("File loaded",""+f$,0)
      
     FreeDropFiles (*dropped)

Code: Select all

Case #Gadget_Load 
                If f$<>"" 
                If loaded 
                  MP3_Free(1) 
                  loaded=#False 
                EndIf 
                If MP3_Load(1,loaded) 
                  max=MP3_GetLength(1) 
                  SetVol(MP3_GetVolume(1)/10) 
                  SetSpeed(MP3_GetSpeed(1)/10) 
                  SetPosition(0,max) 
                  loaded=#True 
                  MP3_Play(1)

Thanks for giving me your time and reading my posts,[/code]
1.3AMD, 2x 256 sdr, 32 AGP
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Post by Denis »

Bong-Mong,

i don't know if i understand what is wrong.
i've rewrited a bit the #WM_DROPFILES event

Code: Select all

Case #WM_DROPFILES 
  dropped .l = EventwParam()
;  with the first call of DragQueryFile_(), you will get the number of file/folder drag'nd dropped

  num.l = DragQueryFile_(dropped , -1, "", 0)  ; you don't need to put a string (temp$) as third param
                                               ; only "" works well
  
  For index = 0 To num - 1
;   inside this loop, each first call of DragQueryFile_() will return the buffer size needed
;   for the file/folder string
    BufferSize.l = DragQueryFile_(dropped , index, 0, 0)
    File.s = Space(BufferSize)
    BufferSize + 1  ; add one because the last param of DragQueryFile need the length + 1 for 
                    ; the terminating null character of the string but first call of DragQueryFile_()
                    ; return a count of the characters copied, not including the terminating null character
    DragQueryFile_(dropped, index, File, BufferSize)
;   here you could process what you whant to to for all the returned files by DragQueryFile_()
;   inside this loop
;
;   for example, test if it is a folder or a file and if it is a file, test if it is a mp3

    If FileSize(File) = -2  ; it's a folder
;      do what you whant here

    Else
       If LCase(GetExtensionPart(File)) = "mp3" 
       ; here you do what you want with your mp3 file
      ; may be you could here add the item to the list with addgadgetitem() ?
       EndIf
    ElseIf 

  Next
; when it's finished whit the dropped files/folders
  DragFinish_(dropped)
This code is adapted from a piece of code i use wich is running without problems.


I don't understand what you do with this code

Code: Select all

For files = 0 To num - 1 
  f$ + GetDropFile (*dropped, files) + Chr (13) 
Next 

AddGadgetItem(#Playlist, -1,f$ ,0 ) 
f$ = GetGadgetItemText(#Playlist, 1, 0) 
Fisrt, f$ will get all the names of dropped files

then you add the entiere string (f$) at the End of your ListIcon (last item).
I wonder how is the result ?

And finally you get the text from the item 1 of your Listicon.
Dont remeber that the first item has index 0. Is it what you whant to get, always the same item ?

Bong-Mong, i don't know if it help you. It will be better if you send more code because it's difficult to understand when we don't know some procedures content.


Denis
A+
Denis
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Post by Bong-Mong »

Please run code,

i want loaded button to load mp3 file from listicongadget
result to = loaded

run code and press down button to see playlist

Code: Select all


Global FontID1
FontID1 = LoadFont(1, "Comic Sans MS", 8)
Global FontID2
FontID2 = LoadFont(2, "Symbol", 10)
Global HintergrundFarbe1 
Global HintergrundFarbe2 

HintergrundFarbe1=CreateSolidBrush_(RGB(0,0,0))         ; schwarz 
HintergrundFarbe2=CreateSolidbrush_(RGB(255,255,255)) 


Dim Progress.l(34)

Enumeration 0 
  #MP3_Unknown 
  #MP3_Stopped 
  #MP3_Playing 
  #MP3_Paused 
EndEnumeration 




  #Window_0 = 0
;
Enumeration
  #Gadget_Position
  #Gadget_PositionTxt
  #Gadget_PositionTxt1
  #ProgressBar_0
  #Gadget_Mute
  #Gadget_Load
  #Gadget_Play
  #Gadget_Pause
  #Gadget_Stop
  #Frame3D_0
  #Gadget_Volume
  #Gadget_VolumeTxt
  #Gadget_Speed
  #Gadget_SpeedTxt
  #Gadget_EC
  #Playlist
  #up
  #random
  #down
EndEnumeration


  Global  blauw
  Global  black
blauw=CreateSolidBrush_(RGB($67,$32,$98))
black=CreateSolidBrush_(RGB($00,$00,$00))
Procedure myCallback(WindowID, Message, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  Select Message
  Case #WM_CTLCOLORSTATIC
    Select lparam
    Case GadgetID(#Gadget_Volume)
      SetBkMode_(wParam,#TRANSPARENT)
      SettextColor_(wParam, $FFFFFF)
      Result = blauw
    Case GadgetID(#Gadget_Mute)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = blauw
    Case GadgetID(#Frame3D_0)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = black
     Case GadgetID(#Gadget_VolumeTxt)
      SetBkMode_(wParam,#TRANSPARENT)
      SettextColor_(wParam, $FFFFFF)
      Result = black
    Case GadgetID(#Gadget_SpeedTxt)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = black
   Case GadgetID(#Gadget_VolumeTxt)
      SetBkMode_(wParam,#TRANSPARENT)
      SettextColor_(wParam, $FFFFFF)
      Result = black
   Case GadgetID(#Gadget_Position)
      SetBkMode_(wParam,#TRANSPARENT)
      SettextColor_(wParam, $FFFFFF)
      Result = blauw
    Case GadgetID(#Gadget_Speed)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = blauw
     Case GadgetID(#Gadget_EC)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = blauw
     Case GadgetID(#Gadget_PositionTxt)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = black
     Case GadgetID(#Gadget_PositionTxt1)
      SetBkMode_(wParam,#TRANSPARENT)
      SetTextColor_(wParam, $FFFFFF)
      Result = black
    EndSelect
  EndSelect
  ProcedureReturn Result
EndProcedure


hWnd = OpenWindow(#Window_0, 278, 107, 351, 261,  #PB_Window_SystemMenu | #PB_Window_TitleBar , "Tiny MP3 Player[+]")
    If hWnd
  SetWinBackgroundColor(hWnd, RGB($67,$32,$98))
  SetForeGroundWindow_(hWnd)
  SetWindowCallback(@myCallback())


     
    
    If CreateGadgetList(WindowID())
      TrackBarGadget(#Gadget_Position, 20, 140, 310, 25, 0, 1000)
      TextGadget(#Gadget_PositionTxt,  131,80,100,36,"")
      TextGadget(#Gadget_PositionTxt1,  131,98,100,18,"")
      ProgressBarGadget(#ProgressBar_0, 20, 170, 310, 15, 0, 1000, #PB_ProgressBar_Smooth)
      SetProgressBarColor(#ProgressBar_0, #Black, RGB($67,$32,$98))
      CheckBoxGadget(#Gadget_Mute, 30, 200, 70, 20, "Mute")
      ButtonGadget(#Gadget_Load, 20, 10, 60, 40, "Load")
      ButtonGadget(#Gadget_Play, 100, 10, 70, 40, "Play")
      ButtonGadget(#Gadget_Pause, 180, 10, 70, 40, "Pause")
      ButtonGadget(#Gadget_Stop, 270, 10, 60, 40, "Stop")
      Frame3DGadget(#Frame3D_0, 20, 60, 310, 60, "MP3 Infomation", #PB_Frame3D_Single)
      TrackBarGadget(#Gadget_Volume, 20, 230, 130, 20, 0, 100)
      TextGadget(#Gadget_VolumeTxt,  21,82,100,18,"Volume")
      TrackBarGadget(#Gadget_Speed, 130, 200, 200, 20, 90, 120)
      TextGadget(#Gadget_SpeedTxt,  21,100,100,18,"Play Speed")
      TrackBarGadget(#Gadget_EC, 250, 230, 80, 20, 0, 1, #PB_TrackBar_Ticks)
      SetGadgetState(#Gadget_EC, 0)
      
     LI= ListIconGadget(#Playlist, 10, 260, 330, 150,"Tracklist",255)
      SendMessage_(LI, #LVM_SETBKCOLOR,0,RGB($00,$00,$00))
      SendMessage_(LI, #LVM_SETTEXTCOLOR,0,RGB($FF,$FF,$FF))
      SendMessage_(LI, #LVM_SETTEXTBKCOLOR,0,RGB($00,$00,$00))
      ButtonGadget(#up, 190, 230, 20, 20, "Ã
1.3AMD, 2x 256 sdr, 32 AGP
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Post by Denis »

Bong-Mong

i've writted some little procedures

I do this :

I've added the option #PB_ListIcon_AlwaysShowSelection to the listIcon. You could remove it if you want.
I've added a second column to the list with a width of 0, so this column doesn't appear, and i lock the size of the first column (index 0). By this way, it's not possible to resize the first column with the mouse.
The first column has the size of the main window of the ListiconGadget
I use SetColumnWidth() and LockColumnSize() from my library MoreListIconGadget to do this.

I've created the procedure GetDroppedFiles() to get all files name dropped and i store the file name in the first column of the ListIcon and i store the Path into the second column and because its size = 0, it doesn't appear. Because if you store the Path name + the file name in the 1st column, it will be difficult to read quickly the name if it is long.

I've create the procedure LoadFileFromList() to load the name from the list, it's not complex and they are another ways to do that.

I've create (but it's not used in the code) the procedure GetMp3FileName() to get file names with an OpenFileRequester (you could select several files) and store the name as i done with the dropped ones.


So, when you get the file name, you have to play the file, but you must write the code.

I hope it will help you.


Denis


Here is the code :

Code: Select all

Global FontID1 
FontID1 = LoadFont(1, "Comic Sans MS", 8) 
Global FontID2 
FontID2 = LoadFont(2, "Symbol", 10) 
Global HintergrundFarbe1 
Global HintergrundFarbe2 

Declare  GetMp3FileName() ; get filename

HintergrundFarbe1=CreateSolidBrush_(RGB(0,0,0))         ; schwarz 
HintergrundFarbe2=CreateSolidbrush_(RGB(255,255,255)) 


Dim Progress.l(34) 

Enumeration 0 
  #MP3_Unknown 
  #MP3_Stopped 
  #MP3_Playing 
  #MP3_Paused 
EndEnumeration 




  #Window_0 = 0 
; 
Enumeration 
  #Gadget_Position 
  #Gadget_PositionTxt 
  #Gadget_PositionTxt1 
  #ProgressBar_0 
  #Gadget_Mute 
  #Gadget_Load 
  #Gadget_Play 
  #Gadget_Pause 
  #Gadget_Stop 
  #Frame3D_0 
  #Gadget_Volume 
  #Gadget_VolumeTxt 
  #Gadget_Speed 
  #Gadget_SpeedTxt 
  #Gadget_EC 
  #Playlist 
  #up 
  #random 
  #down 
EndEnumeration 


  Global  blauw 
  Global  black 
blauw=CreateSolidBrush_(RGB($67,$32,$98)) 
black=CreateSolidBrush_(RGB($00,$00,$00)) 
Procedure myCallback(WindowID, Message, wParam, lParam) 
  Result = #PB_ProcessPureBasicEvents 
  Select Message 
  Case #WM_CTLCOLORSTATIC 
    Select lparam 
    Case GadgetID(#Gadget_Volume) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SettextColor_(wParam, $FFFFFF) 
      Result = blauw 
    Case GadgetID(#Gadget_Mute) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = blauw 
    Case GadgetID(#Frame3D_0) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = black 
     Case GadgetID(#Gadget_VolumeTxt) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SettextColor_(wParam, $FFFFFF) 
      Result = black 
    Case GadgetID(#Gadget_SpeedTxt) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = black 
   Case GadgetID(#Gadget_VolumeTxt) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SettextColor_(wParam, $FFFFFF) 
      Result = black 
   Case GadgetID(#Gadget_Position) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SettextColor_(wParam, $FFFFFF) 
      Result = blauw 
    Case GadgetID(#Gadget_Speed) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = blauw 
     Case GadgetID(#Gadget_EC) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = blauw 
     Case GadgetID(#Gadget_PositionTxt) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = black 
     Case GadgetID(#Gadget_PositionTxt1) 
      SetBkMode_(wParam,#TRANSPARENT) 
      SetTextColor_(wParam, $FFFFFF) 
      Result = black 
    EndSelect 
  EndSelect 
  ProcedureReturn Result 
EndProcedure 


hWnd = OpenWindow(#Window_0, 278, 107, 351, 261,  #PB_Window_SystemMenu | #PB_Window_TitleBar , "Tiny MP3 Player[+]") 
    If hWnd 
  SetWinBackgroundColor(hWnd, RGB($67,$32,$98)) 
  SetForeGroundWindow_(hWnd) 
  SetWindowCallback(@myCallback()) 
  
    
    If CreateGadgetList(WindowID()) 
      TrackBarGadget(#Gadget_Position, 20, 140, 310, 25, 0, 1000) 
      TextGadget(#Gadget_PositionTxt,  131,80,100,36,"") 
      TextGadget(#Gadget_PositionTxt1,  131,98,100,18,"") 
      ProgressBarGadget(#ProgressBar_0, 20, 170, 310, 15, 0, 1000, #PB_ProgressBar_Smooth) 
      SetProgressBarColor(#ProgressBar_0, #Black, RGB($67,$32,$98)) 
      CheckBoxGadget(#Gadget_Mute, 30, 200, 70, 20, "Mute") 
      ButtonGadget(#Gadget_Load, 20, 10, 60, 40, "Load") 
      ButtonGadget(#Gadget_Play, 100, 10, 70, 40, "Play") 
      ButtonGadget(#Gadget_Pause, 180, 10, 70, 40, "Pause") 
      ButtonGadget(#Gadget_Stop, 270, 10, 60, 40, "Stop") 
      Frame3DGadget(#Frame3D_0, 20, 60, 310, 60, "MP3 Infomation", #PB_Frame3D_Single) 
      TrackBarGadget(#Gadget_Volume, 20, 230, 130, 20, 0, 100) 
      TextGadget(#Gadget_VolumeTxt,  21,82,100,18,"Volume") 
      TrackBarGadget(#Gadget_Speed, 130, 200, 200, 20, 90, 120) 
      TextGadget(#Gadget_SpeedTxt,  21,100,100,18,"Play Speed") 
      TrackBarGadget(#Gadget_EC, 250, 230, 80, 20, 0, 1, #PB_TrackBar_Ticks) 
      SetGadgetState(#Gadget_EC, 0) 
      
     LI= ListIconGadget(#Playlist, 10, 260, 330, 150,"Tracklist",255, #PB_ListIcon_AlwaysShowSelection) 
      SetColumnWidth(#Playlist, 0, #PB_Column_Autosize_FromHeader) ; first column width has the width of the 
                                                                   ; listicongadget window
      AddGadgetColumn(#Playlist, 1, "", 0)   ; create a second column, not visible
                                                  ; to store Path files names of Mp3 files
      LockColumnSize(#Playlist, #PB_LockCol | 0)  ; lock size of first column, it's now not possible
                                                  ; to resize the first column with the mouse
      
      SendMessage_(LI, #LVM_SETBKCOLOR,0,RGB($00,$00,$00)) 
      SendMessage_(LI, #LVM_SETTEXTCOLOR,0,RGB($FF,$FF,$FF)) 
      SendMessage_(LI, #LVM_SETTEXTBKCOLOR,0,RGB($00,$00,$00)) 
      ButtonGadget(#up, 190, 230, 20, 20, "Ã
A+
Denis
Bong-Mong
User
User
Posts: 35
Joined: Sat Jan 03, 2004 6:53 pm

Post by Bong-Mong »

Denis, you sure you are only a Apprentice?
lol, good work :)
1.3AMD, 2x 256 sdr, 32 AGP
Post Reply