Ich habe es etwas abgespeckt für ganzahlige Werte.
Code: Alles auswählen
EnableExplicit
Define.i Ev
Procedure checkInt()
;nach Danilo und ts-Soft
Protected gadget.i
Protected start, count, pointcount, new$
gadget=GetActiveGadget()
SendMessage_(GadgetID(gadget), #EM_GETSEL, @start, 0)
Protected txt$ = GetGadgetText(gadget)
Protected *p.Character = @txt$
While *p\c
If count = 0 And *p\c = '-'
new$ + Chr('-')
ElseIf *p\c >= '0' And *p\c <= '9'
new$ + Chr(*p\c)
Else
start - 1
EndIf
*p + SizeOf(Character)
count + 1
Wend
SetGadgetText(gadget, new$)
SendMessage_(GadgetID(gadget), #EM_SETSEL, start, start)
EndProcedure
If OpenWindow(0,0,0,500,400,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
StringGadget(1,50,50,100,50,"")
BindGadgetEvent(1,@checkInt(),#PB_EventType_Change)
EndIf
Repeat
Ev=WaitWindowEvent()
Until Ev=#PB_Event_CloseWindow
Ich finde die wahrscheinlich total einfache Lösung nicht. Vielleicht liegt's auch am Frust über den BL-Abstieg von Paderborn....