Page 1 sur 1
					
				GadgetString
				Publié : dim. 24/sept./2006 20:03
				par LOULOU25
				Quelqu'un sait-il comment on peut limiter l'entrée de données à un certain nombre de caractéres ?
Exemple je ne veux que rentrer des nombres sur 4 positions ex..1234
			 
			
					
				
				Publié : dim. 24/sept./2006 20:59
				par Backup
				comme ça par exemple 
  
 ; 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"   )
            
           EndIf   
       EndIf   
   EndProcedure   
Open_Window_0()
   Repeat     ; Start of the event loop  
    
    Event =    WaitWindowEvent   ()  ; This line waits until an event is received from Windows  
    
       WindowID    =    EventWindow   ()  ; The Window where the event is generated, can be used in the gadget procedures  
    
       GadgetID    =    EventGadget   ()  ; Is it a gadget event?  
    
       EventType    =    EventType   ()  ; The event type  
    
     ;You can place code here, and use the result as parameters for the procedures  
    
       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   
  ;