Code: Select all
; German forum: Translated to English
; Author: OzBernd (updated for PB4.00 by blbltheworm)
; Date: 20. December 2002
; OS: Windows
; Demo: No
; Number String Gadget
; Feel free to use it anywhere, anytime
; Pay attention to decimal and thousandth characters
;------------------------------------------------
Form1_hWnd= OpenWindow(0,100,200,200,200,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
;If Form1_hWnd=0 Or CreateGadgetList(Form1_hWnd)=0 : End : EndIf
If Form1_hWnd=0 : End : EndIf
#number = 1
#label = 2
string_hWnd= StringGadget(#number,10,50,100,20,"")
label_hWnd = TextGadget(#label, 10,30,100,20,"Enter limit")
GadgetToolTip(#number,"Please enter your desired credit limit")
SetActiveGadget(#number)
Repeat
EventID=WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case #number :FakeEndSelect: Gosub number_Click
EndSelect
EndSelect
esc=GetAsyncKeyState_(#VK_ESCAPE)
ret=GetAsyncKeyState_(#VK_RETURN)
Until EventID=#PB_Event_CloseWindow Or esc=-32767 Or ret=-32767
;Swap format according to German convention
text$ = ReplaceString(text$, ",", ".",1,1)
Debug text$
End
; Process input, exclude NoNumbers and place cursor at the end
number_Click:
text$ = GetGadgetText(#number)
If Len(text$)> 0
input.b = Asc(RTrim(Right(text$,1)))
If input >=44 And input <=57 And input <> 47 ; numbers 0 to 9, -.,
Return
Else
SetGadgetText(#number,Left(text$,Len(text$)-1)) ;delete last character
SendMessage_(string_hWnd,#EM_SETSEL, Len(text$),-1) ;Place cursor at the end
EndIf
EndIf
Return
End
; IDE Options = PureBasic v4.00 (Windows - x86)
; Folding = -
; EnableXP