Cursor Position in Plus text boxes |
Author: |
Message: |
win_crook
Junior Member
![*](images/star.gif) ![*](images/star.gif)
Posts: 63 Reputation: 2
31 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Apr 2007
|
O.P. Cursor Position in Plus text boxes
Is there any way I can get the position of the text cursor in a text box in a plus interface?
I need to insert some text at the current cursor position instead of at the end of the box which is the way I'm currently doing it.
Thanks,
David
|
|
04-07-2007 05:47 PM |
|
![](images/pixel.gif) |
Patchou
Messenger Plus! Creator
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
![Avatar](http://www.patchou.com/perso/osaka.jpg)
Posts: 8607 Reputation: 201
43 / / ![Canada Flag](images/flags/ca.png)
Joined: Apr 2002
|
RE: Cursor Position in Plus text boxes
you can send the EM_GETSEL message. In version 4.21, some new functions have been added to add more support for edit controls.
|
|
04-07-2007 06:04 PM |
|
![](images/pixel.gif) |
win_crook
Junior Member
![*](images/star.gif) ![*](images/star.gif)
Posts: 63 Reputation: 2
31 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Apr 2007
|
O.P. RE: Cursor Position in Plus text boxes
Would it be possible for you to give me some guidance on how to do this please? Maybe just a little example to get me started.
|
|
04-07-2007 06:21 PM |
|
![](images/pixel.gif) |
felipEx
Scripting Contest Winner
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
Posts: 378 Reputation: 24
35 / / ![Mexico Flag](images/flags/mx.png)
Joined: Jun 2006
|
RE: RE: Cursor Position in Plus text boxes
quote: Originally posted by Patchou
you can send the EM_GETSEL message. In version 4.21, some new functions have been added to add more support for edit controls.
Hi Patch.
you would have to consider the use of <MaxLength>
it can be possible with API.
code: var EM_LIMITTEXT = 0xC5;
Interop.Call("user32", "SendMessageW", PlusWnd.GetControlHandle("mytxt"), EM_LIMITTEXT, 11 /* or new maxlength value */ , 0);
|
|
04-07-2007 08:48 PM |
|
![](images/pixel.gif) |
win_crook
Junior Member
![*](images/star.gif) ![*](images/star.gif)
Posts: 63 Reputation: 2
31 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Apr 2007
|
O.P. RE: Cursor Position in Plus text boxes
Well I've figured out the EM_GETSEL message and it's working fine now. I'm onto the string processing part now, and I'm getting this error:
quote: Error: Object doesn't support this property or method.
Line: 40. Code: -2146827850.
This is the code, the middle line is line 40:
code: var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start);
var secondHalf = text.substring(Start, before.length);
I'm assuming it's talking about the substring method, but I don't see why it's saying it's unsupported... any ideas?
Thanks,
David
|
|
04-08-2007 12:00 PM |
|
![](images/pixel.gif) |
effection
Full Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
Destroy The Runner
Posts: 135 Reputation: 4
– / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Sep 2006
|
RE: Cursor Position in Plus text boxes
what is $Start defined as?
|
|
04-08-2007 12:32 PM |
|
![](images/pixel.gif) |
win_crook
Junior Member
![*](images/star.gif) ![*](images/star.gif)
Posts: 63 Reputation: 2
31 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Apr 2007
|
O.P. RE: Cursor Position in Plus text boxes
Here is the code that defines start:
code: var EM_GETSEL = 0xB0;
var EM_SETSEL = 0xB1;
var Start = Interop.Allocate(32);
Interop.Call("user32", "SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_GETSEL, Start, 0);
|
|
04-08-2007 12:36 PM |
|
![](images/pixel.gif) |
matty
Scripting Guru
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
Posts: 8336 Reputation: 109
39 / / ![Canada Flag](images/flags/ca.png)
Joined: Dec 2002
Status: Away
|
RE: Cursor Position in Plus text boxes
quote: Originally posted by win_crook
Here is the code that defines start:
code: var EM_GETSEL = 0xB0;
var EM_SETSEL = 0xB1;
var Start = Interop.Allocate(32);
Interop.Call("user32", "SendMessageW", Wnd.GetControlHandle("NameEdit"), EM_GETSEL, Start, 0);
When you are allocating memory to a variable you cannot simply reference the variable itself. In this case the value you are trying to read is a DWORD.
You need to replace:
code: var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start);
var secondHalf = text.substring(Start, before.length);
With this
code: var text = Wnd.GetControlText("NameEdit");
var firstHalf = text.substring(0, Start.ReadDWORD(0));
var secondHalf = text.substring(Start.ReadDWORD(0), before.length);
And where does before come into play?
Also why are you allocating 32 bytes of memory to Start? It should be 4.
This post was edited on 04-08-2007 at 02:44 PM by matty.
|
|
04-08-2007 02:44 PM |
|
![](images/pixel.gif) |
win_crook
Junior Member
![*](images/star.gif) ![*](images/star.gif)
Posts: 63 Reputation: 2
31 / / ![United Kingdom Flag](images/flags/gb.png)
Joined: Apr 2007
|
O.P. RE: Cursor Position in Plus text boxes
Thanks a lot for that ![:D](images/smilies/msn_grin.gif) ... the before doesn't come into play, I forgot to change it to text for this example. It's all working fine now.
|
|
04-08-2007 02:49 PM |
|
![](images/pixel.gif) |
Felu
Veteran Member
![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif) ![*](images/star.gif)
Posts: 2223 Reputation: 72
30 / / ![India Flag](images/flags/in.png)
Joined: Apr 2006
Status: Away
|
RE: Cursor Position in Plus text boxes
quote: Originally posted by effection
$Start
He never used the variable $Start. It was Start. Please don't confuse with it. This is not php that you'll need $ for a variable. This is JScript.
This post was edited on 04-08-2007 at 03:41 PM by Felu.
|
|
04-08-2007 03:41 PM |
|
![](images/pixel.gif) |
|