Is it possible to limit the length of an EditControl? |
Author: |
Message: |
MeEtc
Patchou's look-alike
In the Shadow Gallery once again
Posts: 2200 Reputation: 60
38 / /
Joined: Nov 2004
Status: Away
|
O.P. Is it possible to limit the length of an EditControl?
I'm wondering if its possible to make a maximum length of the number of characters that is possible to type into a text box?
I cannot hear you. There is a banana in my ear.
|
|
10-21-2007 07:38 PM |
|
|
vikke
Senior Member
Posts: 900 Reputation: 28
31 / /
Joined: May 2006
|
RE: Is it possible to limit the length of an EditControl?
You code it instead:
code: var MaxLength = 100;
function On<YOUR_EDIT_ID_HERE>Event_EditTextChanged(PlusWnd, ControlId)
{
var Text = PlusWnd.GetControlText(ControlId);
if(Text.length > MaxLength)
{
PlusWnd.SetControlText(ControlId, Text.substr(0, MaxLength));
}
}
I havn't tried it but I think it should work. If it doesn't, I hope you get the idea.
Edit: if you want to add a beep you could use this function.
code: function Beep(frequency, duration)
{
Interop.Call("Kernel32.dll", "Beep", frequency, duration);
}
This post was edited on 10-21-2007 at 07:59 PM by vikke.
|
|
10-21-2007 07:50 PM |
|
|
Mike
Elite Member
Meet the Spam Family!
Posts: 2795 Reputation: 48
32 / /
Joined: Mar 2003
Status: Online
|
RE: Is it possible to limit the length of an EditControl?
quote: Originally posted by vikke
Edit: if you want to add a beep you could use this function.
code:function Beep(frequency, duration)
{
Interop.Call("Kernel32.dll", "Beep", frequency, duration);
}
Beep will use the computer speaker to generate a sound.
If you want to use a waveform sound, you have to use MessageBeep.
|
|
10-21-2007 09:22 PM |
|
|
TYL3R
Junior Member
MP!L Scripter =]
Posts: 24 Reputation: -4
31 / /
Joined: Oct 2006
|
RE: Is it possible to limit the length of an EditControl?
Beep doesn't use the speaker to generate a sound.
It uses the sound card or something.
|
|
10-21-2007 09:40 PM |
|
|
MeEtc
Patchou's look-alike
In the Shadow Gallery once again
Posts: 2200 Reputation: 60
38 / /
Joined: Nov 2004
Status: Away
|
O.P. RE: Is it possible to limit the length of an EditControl?
Heh, thanks. All I need was the text field limit, thanks
I cannot hear you. There is a banana in my ear.
|
|
10-21-2007 09:47 PM |
|
|
deAd
Scripting Contest Winner
Posts: 1060 Reputation: 28
– / /
Joined: Jan 2006
|
RE: Is it possible to limit the length of an EditControl?
If you're not limiting it based on a specific pattern, then it'd be better to just use EM_LIMITTEXT.
|
|
10-21-2007 09:56 PM |
|
|
MeEtc
Patchou's look-alike
In the Shadow Gallery once again
Posts: 2200 Reputation: 60
38 / /
Joined: Nov 2004
Status: Away
|
O.P. RE: Is it possible to limit the length of an EditControl?
Actually, it is a pattern of sorts. The text field is going to be for a hex colour value
I cannot hear you. There is a banana in my ear.
|
|
10-21-2007 09:58 PM |
|
|
felipEx
Scripting Contest Winner
Posts: 378 Reputation: 24
35 / /
Joined: Jun 2006
|
RE: Is it possible to limit the length of an EditControl?
quote: Originally posted by MeEtc
I'm wondering if its possible to make a maximum length of the number of characters that is possible to type into a text box?
something like this? =]
code: PlusWnd.SendControlMessage("YourEditControlId", 0xC5 /*EM_LIMITTEXT*/, 6 /*new length*/, 0);
This post was edited on 10-21-2007 at 10:02 PM by felipEx.
|
|
10-21-2007 10:01 PM |
|
|
deAd
Scripting Contest Winner
Posts: 1060 Reputation: 28
– / /
Joined: Jan 2006
|
RE: RE: Is it possible to limit the length of an EditControl?
quote: Originally posted by MeEtc
Actually, it is a pattern of sorts. The text field is going to be for a hex colour value
For patterns it's better to monitor each character as it's entered so you can determine if it fits the pattern and then cancel it
|
|
10-21-2007 10:27 PM |
|
|
|