Page 1 sur 1

ScrollBarGadget et gestion des évenement...

Publié : sam. 10/oct./2009 23:02
par GallyHC
Bonjour tous,

J'utililse un "ScrollBarGadget", mais je voudrais que quand je deplace de scroller sa me renvois la valeur de la position. Pour le moment as fonctionne apars que c'est quand on lache le scroller que sa me donne la position.

Y a t'il une solution a ce problème.

Cordialement,
GallyHC

Re: ScrollBarGadget et gestion des évenement...

Publié : dim. 11/oct./2009 19:12
par zaphod
Est ce que c'est ce que tu cherches :

Code : Tout sélectionner


;{- Enumerations / DataSections
;{ Windows
Enumeration
  #Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
  #ScrollBar_0
  #Text_1
EndEnumeration
;}
;}
 Procedure winCallback(WindowID, Message, wParam, lParam)
    Resultat = #PB_ProcessPureBasicEvents
    ;
    Protected HoldInfo.SCROLLINFO

    
    If message=#WM_HSCROLL
     If lParam = GadgetID(#scrollbar_0)
      HoldInfo\cbSize = SizeOf(SCROLLINFO)
      ;
      HoldInfo\fMask = #SIF_ALL
      ;
      GetScrollInfo_(lParam, #SB_CTL, @HoldInfo) 
      ;
    SetGadgetText(#text_1,Str(holdinfo\npos))
    EndIf
    
    EndIf
    ;
    ProcedureReturn Resultat
  EndProcedure


Procedure OpenWindow_Window_0()
  If OpenWindow(#Window_0, 450, 200, 364, 157, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
    ScrollBarGadget(#ScrollBar_0, 75, 45, 185, 30, 0, 100, 0)
    TextGadget(#Text_1, 110, 5, 125, 25, "Gadget_1")
  EndIf
EndProcedure

OpenWindow_Window_0()
  SetWindowCallback(@WinCallback())    
;{- Event loop
Repeat
  Select WaitWindowEvent()
    ; ///////////////////
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #ScrollBar_0
        Case #Text_1
      EndSelect
    ; ////////////////////////
    Case #PB_Event_CloseWindow
      Select EventWindow()
        Case #Window_0
          CloseWindow(#Window_0)
          Break
      EndSelect
  EndSelect
ForEver
;
;}

Re: ScrollBarGadget et gestion des évenement...

Publié : dim. 11/oct./2009 23:13
par GallyHC
Bonjour zaphod,

Oui en gros c bien cela que je recherche, mais en plus compatible Windows, Linux et MacOS. Sinon je te remercie, car cela me donne déjà une piste de travail.

Amitié,
GallyHC