Page 1 sur 1

Problème avec le Min et le Max du SpinGadget

Publié : lun. 04/août/2008 22:40
par Octavius
Les valeurs minimum et maximum du SpinGadget doivent être un word, càd comprises entre -32768 et +32767, mais j'ai besoin d'un SpinGadget qui puisse dépasser les 100 000, comment changer les minimum et maximum en variables de type long ?

Publié : mar. 05/août/2008 0:15
par Anonyme
Non , mis à part refaire un gadget , je vois pas :?

Publié : mar. 05/août/2008 1:12
par Chris
Il faut passer par des SendMessage_() (Ce qui limite l'utilisation à Windows)

Pour toutes les utilisations du gadget, les commandes de Pure ne seront plus valables. Il faudra tout faire avec les "SendMessage" à Billou.
(Tout au moins en ce qui concerne les commandes qui modifient la valeur interne du gadget)

Code : Tout sélectionner

#Win  = 0 : #Spin = 0

#UDM_SETPOS32 = #WM_USER + 113
#UDM_GETPOS32 = #WM_USER + 114

If OpenWindow(#Win, 0, 0, 200, 100, "Spin", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateGadgetList(WindowID(#Win))
    
    SpinGadget(#Spin, 20, 20, 100, 25, 0, 0, #PB_Spin_Numeric)
    
    hSpin = FindWindowEx_(WindowID(#Win), GadgetID(#Spin), #Null, #Null)
    
    SendMessage_(hSpin, #UDM_SETRANGE32, -200000, 200000) ; Règle la portée du gadget
    SendMessage_(hSpin, #UDM_SETPOS32, 0, -158963)        ; Règle la valeur
    
    SetGadgetText(#Spin, Str(SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)))
    
  EndIf
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = #True
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Spin
            Pos = SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)
            SendMessage_(hSpin, #UDM_SETPOS32, 0, Pos)
            SetGadgetText(#Spin, Str(Pos))

        EndSelect
    EndSelect
  Until Quit
EndIf

End

Publié : mar. 05/août/2008 12:55
par Octavius
J'ai essayé d'adapter ton code à mon programme, mais ça ne convient pas parce le SpinGadget est dans un panneau. Du coup le hSpin est 0 et le SpinGadget est inutilisable ! Comment corriger ça ?

Code : Tout sélectionner

#Win  = 0 : #Spin = 0 : #Panel = 1

#UDM_SETPOS32 = #WM_USER + 113
#UDM_GETPOS32 = #WM_USER + 114

If OpenWindow(#Win, 0, 0, 200, 100, "Spin", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateGadgetList(WindowID(#Win))
    
    PanelGadget(#Panel,10,10,180,80)
    AddGadgetItem(#Panel,-1,"Onglet")
      
      SpinGadget(#Spin, 20, 20, 100, 25, 0, 0, #PB_Spin_Numeric)
     
      hSpin = FindWindowEx_(WindowID(#Win), GadgetID(#Spin), #Null, #Null)
     
      SendMessage_(hSpin, #UDM_SETRANGE32, -200000, 200000) ; Règle la portée du gadget
      SendMessage_(hSpin, #UDM_SETPOS32, 0, -158963)        ; Règle la valeur
     
      SetGadgetText(#Spin, Str(SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)))
      
      Debug hSpin
      
    CloseGadgetList()
   
  EndIf
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = #True
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Spin
            Pos = SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)
            SendMessage_(hSpin, #UDM_SETPOS32, 0, Pos)
            SetGadgetText(#Spin, Str(Pos))

        EndSelect
    EndSelect
  Until Quit
EndIf

End

Publié : mar. 05/août/2008 15:57
par Chris
Ben à mon avis, à la place du WIndowId(), tu mets le GadgetId() de ton panneau, tout simplement

Code : Tout sélectionner

hSpin = FindWindowEx_(GadgetID(#TonPanneau), GadgetID(#Spin), #Null, #Null) 
J'ai pas testé, (vu que je sais pas ce que tu appelles "un panneau"), mais essaye et tu verras si ça fonctionne

Publié : mar. 05/août/2008 16:44
par Octavius
Ben un panneau, un PanelGadget quoi ! :)

Le code que je t'ai posté contient mon fameux PanelGadget.

Remplacer WindowID() par GadgetID() ne fonctionne pas, tu peux tester avec le code que j'ai posté ci-dessus.

Publié : mar. 05/août/2008 17:10
par Chris
Octavius a écrit :Ben un panneau, un PanelGadget quoi ! :)

Le code que je t'ai posté contient mon fameux PanelGadget.

Remplacer WindowID() par GadgetID() ne fonctionne pas, tu peux tester avec le code que j'ai posté ci-dessus.
Euh!... J'avais même pas vu que t'avais mis un code! :oops:


Essaye ça.

Code : Tout sélectionner

#Win  = 0 

Enumeration
  #Spin = 0
  #Panneau
EndEnumeration

#UDM_SETPOS32 = #WM_USER + 113
#UDM_GETPOS32 = #WM_USER + 114

If OpenWindow(#Win, 0, 0, 200, 200, "Spin", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If CreateGadgetList(WindowID(#Win))
    
    PanelGadget(#Panneau, 5, 5, 190, 190)
      AddGadgetItem(#Panneau, -1, "Onglet 1")
      
      SpinGadget(#Spin, 10, 20, 170, 20, 0, 0, #PB_Spin_Numeric)
      
      hSpin = FindWindowEx_(GetWindowLong_(GadgetID(#Spin), #GWL_HWNDPARENT), GadgetID(#Spin), #Null, #Null)
      
    CloseGadgetList()
    
    
    SendMessage_(hSpin, #UDM_SETRANGE32, -200000, 200000) ; Règle la portée du gadget
    SendMessage_(hSpin, #UDM_SETPOS32, 0, -199963)        ; Règle la valeur
    
    SetGadgetText(#Spin, Str(SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)))
    
  EndIf
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = #True
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Spin
            Pos = SendMessage_(hSpin, #UDM_GETPOS32, 0, 0)
            SendMessage_(hSpin, #UDM_SETPOS32, 0, Pos)
            SetGadgetText(#Spin, Str(Pos))
            
        EndSelect
    EndSelect
  Until Quit
EndIf

End

Publié : mar. 05/août/2008 17:32
par Octavius
Merci ça marche maintenant! :D

Publié : mar. 05/août/2008 17:35
par Chris
Octavius a écrit :Merci ça marche maintenant! :D
Nickel!


Pas si largué que ça, le vioque, finalement! :mrgreen: