A constant such in the way:
#PB_String_MaxLength
Thanks for reading
[Implemented] StringGadget maximal length
[Implemented] StringGadget maximal length
PB 4 | WinXP_SP2
-
- User
- Posts: 82
- Joined: Tue May 03, 2005 2:51 am
- Location: Wheeling, Illinois, USA
- Contact:
Actually it's easy enough to do by yourself. This snippet is for PB4, Windows only, and handles backspace, delete, paste and such things.
Code: Select all
Procedure stringlength(gadget.l, length.l)
text$ = GetGadgetText(gadget)
textlength.l = Len(text$)
If textlength > length
SendMessage_(GadgetID(gadget), #EM_GETSEL, @startpos.l, @endpos.l)
SetGadgetText(gadget, Left(text$, startpos - 1) + Mid(text$, startpos + 1, Len(text$) - 1))
SendMessage_(GadgetID(gadget), #EM_SETSEL, startpos - 1, startpos - 1)
FlashWindow_(WindowID(0), 1)
MessageBeep_(-1)
EndIf
EndProcedure
OpenWindow(0, 0, 0, 320, 240, "Test")
CreateGadgetList(WindowID(0))
StringGadget(0, 20, 20, 200, 20, "")
StringGadget(1, 20, 50, 200, 20, "")
StringGadget(2, 20, 80, 200, 20, "")
StringGadget(3, 20, 110, 200, 20, "")
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
gadget.l = EventGadget()
Select gadget
Case 0,1
stringlength(gadget, 20)
Case 2
stringlength(gadget, 10)
Case 3
stringlength(gadget, 32)
EndSelect
EndSelect
ForEver
We could add an attribute for that, you're right. For Windows you can also use that:
Code: Select all
OpenWindow(0, 0, 0, 320, 240, "Test")
CreateGadgetList(WindowID(0))
StringGadget(0, 20, 20, 200, 20, "")
StringGadget(1, 20, 50, 200, 20, "")
StringGadget(2, 20, 80, 200, 20, "")
StringGadget(3, 20, 110, 200, 20, "")
SendMessage_(GadgetID(0), #EM_LIMITTEXT, 3, 0)
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
gadget.l = EventGadget()
EndSelect
ForEver