How to control string gadget length

Just starting out? Need help? Post your questions and find answers here.
soswing
New User
New User
Posts: 2
Joined: Fri Jun 27, 2003 7:02 pm

How to control string gadget length

Post by soswing »

I'm a newbie to Pure Basic.
Can anybody help me how to control the max length of a string gadget?
What I mean: If I want to have an input for example max. 4 characters,
is there any solution to allow only 4 charecters to be keyed in.
It is not the way, that I check the length after the user made an
input of 23 characters, then I warn him: only 4 characters are allowed.
I want to make a possibility to input only 4 characters on the
windows screen.

Thanks,

soswing
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

I think that for now you have to use the API to do this, on WinOS platforms you use this:

Code: Select all

SendMessage_(GadgetID(#YOUR_STRING_GADGET), #EM_LIMITTEXT, 4, 0)
; where 4 is the char limit you set
soswing
New User
New User
Posts: 2
Joined: Fri Jun 27, 2003 7:02 pm

How to control string gadget length

Post by soswing »

Thanks Pupil,

It works fine!! :D

soswing
Post Reply