What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Is it possible to limit the length of an EditControl?

Is it possible to limit the length of an EditControl?
Author: Message:
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
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?
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
10-21-2007 07:38 PM
Profile PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
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
Profile E-Mail PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
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.
YouTube closed-captions ripper (also allows you to download videos!)
10-21-2007 09:22 PM
Profile E-Mail PM Web Find Quote Report
TYL3R
Junior Member
**

Avatar
MP!L Scripter =]

Posts: 24
Reputation: -4
31 / Male / Flag
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.
- Youtube Info
     Thread

- MsgPlus! Jukebox
     Thread
10-21-2007 09:40 PM
Profile E-Mail PM Web Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
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
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
10-21-2007 09:47 PM
Profile PM Web Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
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
Profile PM Find Quote Report
MeEtc
Patchou's look-alike
*****

Avatar
In the Shadow Gallery once again

Posts: 2200
Reputation: 60
38 / Male / Flag
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
[Image: signature/]     [Image: sharing.png]
I cannot hear you. There is a banana in my ear.
10-21-2007 09:58 PM
Profile PM Web Find Quote Report
felipEx
Scripting Contest Winner
***


Posts: 378
Reputation: 24
35 / Male / Flag
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
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
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
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On