[Resolu] stringgadget comment limiter la saisie ?

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
coxco
Messages : 92
Inscription : ven. 06/juin/2008 16:04

[Resolu] stringgadget comment limiter la saisie ?

Message par coxco »

Salut

Voila je cherche comment limiter la saisie de caracteres dans un stringgadget
sans passer par keyboard si possible.

Merci
Dernière modification par coxco le lun. 01/sept./2008 9:57, modifié 1 fois.
Mytic
Messages : 466
Inscription : mer. 25/juil./2007 0:13

Message par Mytic »

Bonjour,
Il suffit de faire comme ceci :

Code : Tout sélectionner

SendMessage_(GadgetID(#StringGadget), #EM_LIMITTEXT, 10, 0)
#StringGadget => Numéro du gadget
10 => La limite en caractères
coxco
Messages : 92
Inscription : ven. 06/juin/2008 16:04

Merci

Message par coxco »

Super Merci

:)
Avatar de l’utilisateur
Ar-S
Messages : 9540
Inscription : dim. 09/oct./2005 16:51
Contact :

Message par Ar-S »

hum c'est bon à savoir, merci Mytic
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

le meme chose un peut plus long, mais sans API !! (donc compatible Linux) :D

Code : Tout sélectionner


; Codé par Dobro 
; en purebasic 4.00
;- Window Constants
;
Enumeration
      #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
      #String_0
      #Text_0
EndEnumeration


Procedure Open_Window_0()
      If OpenWindow(#Window_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
            If CreateGadgetList(WindowID(#Window_0))
                  StringGadget(#String_0, 50, 30, 150, 20, "",#PB_String_Numeric )
                  TextGadget(#Text_0, 50, 60, 140, 20, "Limité a 6 caracteres chiffre")
                  
            EndIf
      EndIf
EndProcedure

Open_Window_0()

Repeat ; Start of the event loop 
      Event = WaitWindowEvent() ;  
      WindowID = EventWindow() ; 
      GadgetID = EventGadget() ;  
      EventType = EventType() ;  
      ; 
      If Event = #PB_Event_Gadget 
            If GadgetID = #String_0
                  text$=GetGadgetText(#String_0)
                  If Len( text$)>6 
                        text$= Left(text$,6)
                        StringGadget(#String_0, 50, 30, 150, 20, "",#PB_String_ReadOnly|#PB_String_Numeric  ) 
                        StringGadget(#String_0, 50, 30, 150, 20, "",#PB_String_Numeric   )
                        SetGadgetText(#String_0, text$)
                  EndIf 
            EndIf 
      EndIf 
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
;
coxco
Messages : 92
Inscription : ven. 06/juin/2008 16:04

Message par coxco »

C'est pas mal non plus
merci
Répondre