469,271 Members | 1,711 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

SelStart in Large Textbox

Hi,

Is there a way to use the SelStart functionality in a textbox that has
more than 32,767 characters in it, when the cursor is beyond the
32,767th characterz?

SelStart is an integer, and it wraps around to negative numbers when
going beyond this upper limit.

Thanks,
Oren

Nov 13 '05 #1
6 8142
THis came up a while ago. You will have to use the API's to send
amessage to the textbox directly. THere is a thread here on this
subject:

http://groups-beta.google.com/group/...s.formscoding/
browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E
CKANKAR&rnum=5&hl=en#5ce723032a342049

Post back if you need some help with the API declarations.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Oren" <or**@gdblegal.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi,

Is there a way to use the SelStart functionality in a textbox that has
more than 32,767 characters in it, when the cursor is beyond the
32,767th characterz?

SelStart is an integer, and it wraps around to negative numbers when
going beyond this upper limit.

Thanks,
Oren


Nov 13 '05 #2
Hi Stephen,

Thanks for your advice. Have been under the weather, and so the project
I'm working on was on hold...

Please give some tips regarding the API declarations. How to find where
the cursor is in the textbox and how to set this value when it's beyond
the 32767th character.

All the best,
Oren
-------------

Stephen Lebans wrote:
THis came up a while ago. You will have to use the API's to send
amessage to the textbox directly. THere is a thread here on this
subject:

http://groups-beta.google.com/group/...s.formscoding/ browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E CKANKAR&rnum=5&hl=en#5ce723032a342049

Post back if you need some help with the API declarations.


Nov 13 '05 #3
Hi Stephen,

Thanks for your advice. Have been under the weather, and so the project
I'm working on was on hold...

Please give some tips regarding the API declarations. How to find where
the cursor is in the textbox and how to set this value when it's beyond
the 32767th character.

All the best,
Oren
-------------

Stephen Lebans wrote:
THis came up a while ago. You will have to use the API's to send
amessage to the textbox directly. THere is a thread here on this
subject:

http://groups-beta.google.com/group/...s.formscoding/ browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E CKANKAR&rnum=5&hl=en#5ce723032a342049

Post back if you need some help with the API declarations.


Nov 13 '05 #4
Oren what do you have so far?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Oren" <or**@gdblegal.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi Stephen,

Thanks for your advice. Have been under the weather, and so the project I'm working on was on hold...

Please give some tips regarding the API declarations. How to find where the cursor is in the textbox and how to set this value when it's beyond the 32767th character.

All the best,
Oren
-------------

Stephen Lebans wrote:
THis came up a while ago. You will have to use the API's to send
amessage to the textbox directly. THere is a thread here on this
subject:

http://groups-beta.google.com/group/...s.formscoding/

browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E
CKANKAR&rnum=5&hl=en#5ce723032a342049

Post back if you need some help with the API declarations.


Nov 13 '05 #5
Stephen -

I'm quite unfamiliar with API declarations. Up until now, I've been
using the selStart property of a textbox to find/set the location of a
cursor in a textbox.

Oren

Nov 13 '05 #6
This code was tested on a form with a CommandButton, Unbound TextBox and
a TextBox bound to a Memo field. You can figure out the names of the
controls from the code:

When you are sending the EM_GETSEL message you are sending the variables
address(ByREF) so that the API can return the Selstart and SelEnd values
back to you.

When you are sending the EM_SETSEL message you are sending the variables
actual values(ByVal) since you are sending not receiving values.
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByRef wParam As Long, _
ByRef lParam As Long) As Long

Private Declare Function GetFocus Lib "user32" () As Long
Private Const EM_GETSEL = &HB0
Private Const EM_SETSEL = &HB1
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Private Const EM_LINEFROMCHAR = &HC9

Private Sub testmemo_Click()
Dim lCurPos As Long
Dim hWnd As Long

' Start and End of current selection
Dim lStart As Long, lEnd As Long

' The TextBox control MUST HAVE THE FOCUS
Me.testmemo.SetFocus
' Get the hWnd of the Active window
hWnd = GetFocus

'get the character position of the cursor
Call SendMessage(hWnd, EM_GETSEL, lStart, lEnd)
Me.txtSelStart.Value = "Start:" & lStart & vbCrLf & "End:" & lEnd
End Sub

Private Sub cmdSelStart_Click()
On Error GoTo Err_cmdSelStart_Click

Dim lCurPos As Long
Dim hWnd As Long

' Start and End of current selection
Dim lStart As Long, lEnd As Long

' The TextBox control MUST HAVE THE FOCUS
Me.testmemo.SetFocus
' Get the hWnd of the Active window
hWnd = GetFocus

lStart = IIf(CLng(Me.txtSelStart.Value > -1), Me.txtSelStart.Value, 0)
'Set the character position of the cursor
Call SendMessage(hWnd, EM_SETSEL, ByVal lStart, ByVal lStart + 0)

Exit_cmdSelStart_Click:
Exit Sub

Err_cmdSelStart_Click:
MsgBox Err.Description
Resume Exit_cmdSelStart_Click

End Sub

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Oren" <or**@gdblegal.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Stephen -

I'm quite unfamiliar with API declarations. Up until now, I've been
using the selStart property of a textbox to find/set the location of a
cursor in a textbox.

Oren


Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hank | last post: by
2 posts views Thread by Dennis C. Drumm | last post: by
3 posts views Thread by Hai Nguyen | last post: by
2 posts views Thread by Papa.Coen | last post: by
2 posts views Thread by =?Utf-8?B?SC5CLg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.