Page 1 sur 1

ExplorerListGadget [RESOLU]

Publié : mar. 10/juil./2007 13:53
par MetalOS
Salut tous le monde, je voulais savoir si on pouvait executer un fichier présent dans un ExplorerListGadget. En gros je veut charger le contenue d'un répertoir ou d'un disque et pouvoir executer un fichier en double cliquant dessus, c possible ? car je ne trouve pas de commande dans l'aide de PB pour l'ExplorerListGadget. A moin que je n'utilise pas le bon gadget.

Voici un exemple de source.

Code : Tout sélectionner

;{- Enumerations / DataSections
;{ Windows
 a$ = "a:\"
 c$ = "c:\"

Enumeration
  #Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #ExplorerList_0
  #Button_1
  #Button_2
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 400, 238, "Test.", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    If CreateGadgetList(WindowID(#Window_0))
      ExplorerListGadget(#ExplorerList_0, 0, 0, 390, 195, "c:\")
      ButtonGadget(#Button_1, 5, 200, 150, 20, "A:")
      ButtonGadget(#Button_2, 160, 200, 150, 20, "C:")
    EndIf
  EndIf
EndProcedure

OpenWindow_Window_0()

;{- Event loop
Repeat
  Event = WaitWindowEvent()
  Select Event
    ; ///////////////////
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = #ExplorerList_0
      ElseIf EventGadget = #Button_1
         SetGadgetText(#ExplorerList_0, a$)
      ElseIf EventGadget = #Button_2
         SetGadgetText(#ExplorerList_0, c$)
      EndIf
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = #Window_0
        CloseWindow(#Window_0)
        Break
      EndIf
  EndSelect
ForEver
;
;}

Publié : mar. 10/juil./2007 14:33
par gnozal
Comme çà par exemple :

Code : Tout sélectionner

;{- Enumerations / DataSections 
;{ Windows 
a$ = "a:\" 
c$ = "c:\" 

Enumeration 
  #Window_0 
EndEnumeration 
;} 
;{ Gadgets 
Enumeration 
  #ExplorerList_0 
  #Button_1 
  #Button_2 
EndEnumeration 
;} 
Define.l Event, EventWindow, EventGadget, EventType, EventMenu 
;} 
Procedure OpenWindow_Window_0() 
  If OpenWindow(#Window_0, 450, 200, 400, 238, "Test.", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar) 
    If CreateGadgetList(WindowID(#Window_0)) 
      ExplorerListGadget(#ExplorerList_0, 0, 0, 390, 195, "c:\") 
      ButtonGadget(#Button_1, 5, 200, 150, 20, "A:") 
      ButtonGadget(#Button_2, 160, 200, 150, 20, "C:") 
    EndIf 
  EndIf 
EndProcedure 

OpenWindow_Window_0() 

;{- Event loop 
Repeat 
  Event = WaitWindowEvent() 
  Select Event 
    ; /////////////////// 
    Case #PB_Event_Gadget 
      EventGadget = EventGadget() 
      EventType = EventType() 
      If EventGadget = #ExplorerList_0 
        If EventType = #PB_EventType_LeftDoubleClick ; <---- On récupère le chemin du fichier sur lequel on a double cliqué ....
          MessageRequester("Double-clic", GetGadgetText(#ExplorerList_0) + GetGadgetItemText(#ExplorerList_0, GetGadgetState(#ExplorerList_0), 0))
        EndIf
      ElseIf EventGadget = #Button_1 
        SetGadgetText(#ExplorerList_0, a$) 
      ElseIf EventGadget = #Button_2 
        SetGadgetText(#ExplorerList_0, c$) 
      EndIf 
      ; //////////////////////// 
    Case #PB_Event_CloseWindow 
      EventWindow = EventWindow() 
      If EventWindow = #Window_0 
        CloseWindow(#Window_0) 
        Break 
      EndIf 
  EndSelect 
ForEver 
; 
;}
Pour exécuter le fichier, remplacer MessageRequester() par RunProgram() par exemple.

Publié : mar. 10/juil./2007 14:44
par MetalOS
Oui c exactement ca merci.