Page 1 sur 1

Interaction ExplorerGadget & StringGadget

Publié : dim. 02/oct./2005 20:04
par Heis Spiter
Voici un bout de code qui montre comment faire interagir deux gadgets et qui montre aussi comment utiliser les types d'évenement.
Ce code demande que l'utilisateur entre un répertoire qui est affiché dans l'ExplorerGadget et vice-versa.

Code : Tout sélectionner

Enumeration
  #Window_0
  #reptxt
  #repcho
  #reptype
EndEnumeration
AppName$ = "Application Name"
LenAppName = Len(AppName$)
If OpenWindow(#Window_0, 298, 148, 502, 369,  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "Install")
  If CreateGadgetList(WindowID())
    TextGadget(#reptxt, 30, 110, 442, 20, "Choose directory where you want to install "+AppName$+" :")
    StringGadget(#reptype, 30, 150, 442, 20, "C:\"+AppName$)
    ExplorerTreeGadget(#repcho, 30, 190, 442, 100, "C:\", #PB_Explorer_NoFiles | #PB_Explorer_NoMyDocuments | #PB_Explorer_AutoSort | #PB_Explorer_NoLines | #PB_Explorer_NoButtons | #PB_Explorer_AlwaysShowSelection)
  EndIf
  Repeat
    Delay(1)
    Event = WindowEvent()
    If Event = #PB_EventGadget
      GadgetID = EventGadgetID()
      If GadgetID = #repcho
        TEvent = EventType()
        If Tevent = #PB_EventType_Change
          If autochange = 0
            SetGadgetText(#reptype, GetGadgetText(#repcho)+AppName$)
          Else
            autochange = 0
          EndIf
        EndIf
      ElseIf GadgetID = #reptype
        TEvent = EventType()
        If Tevent = #PB_EventType_Change
          folder$ = GetGadgetText(#reptype)
          If Right(folder$, LenAppName) = AppName$
            folder$ = Left(folder$, Len(folder$)-LenAppName)
          EndIf
          SetGadgetText(#repcho, folder$)
          autochange = 1
        EndIf
      EndIf
    EndIf
  Until Event = #PB_EventCloseWindow
EndIf