lorsqu'on veut saisir une valeur décimale dans un stringGadget avec l'option numérique
,on ne peut pas saisir le séparateur point.
Le code ci après illustre ce problème .
Code : Tout sélectionner
Define.f nb1,nb2,resultat
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#String_0
#String_1
#Text_0
#Text_1
#Image_0
#Image_1
#Button_0
#Button_1
#Text_2
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Arial", 16, #PB_Font_Bold)
;- Image Plugins
;- Image Globals
Global Image0
Global Image1
;- Catch Images
Image0 = CatchImage(0, ?Image0)
Image1 = CatchImage(1, ?Image1)
;- Images
DataSection
Image0:
IncludeBinary "champignon.bmp"
Image1:
IncludeBinary "araignee.bmp"
EndDataSection
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 600, 300, "Etude StringGadget", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
StringGadget(#String_0, 420, 20, 120, 40, "",#PB_String_Numeric )
StringGadget(#String_1, 420, 80, 120, 40, "",#PB_String_Numeric )
TextGadget(#Text_0, 290, 20, 120, 40, "Rentrez le premier nombre", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Text_1, 290, 80, 120, 40, "Rentrez le deuxième nombre", #PB_Text_Center | #PB_Text_Border)
ImageGadget(#Image_0, 430, 170, 70, 70, Image0)
ImageGadget(#Image_1, 330, 170, 70, 70, Image1)
ButtonGadget(#Button_0, 50, 130, 100, 50, "Calculer")
ButtonGadget(#Button_1, 50, 190, 100, 50, "Quitter")
TextGadget(#Text_2, 40, 20, 160, 80, "", #PB_Text_Center | #PB_Text_Border)
SetGadgetFont(#Text_2, FontID1)
EndIf
EndProcedure
Open_Window_0()
Repeat
Event =WaitWindowEvent()
If Event =#PB_Event_Gadget
Select EventGadget()
Case #String_0
nb1 =ValF(GetGadgetText(#String_0))
Case #String_1
nb2 =ValF(GetGadgetText(#String_1))
Case #Button_0
resultat =nb1 + nb2
SetGadgetText(#Text_2,StrF(resultat,2))
Case #button_1
Event =#PB_Event_CloseWindow
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
merci pour vos remarques