Connecting Tech Pros Worldwide Help | Site Map

SelStart in Large Textbox

Oren
Guest
 
Posts: n/a
#1: Nov 13 '05
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

Stephen Lebans
Guest
 
Posts: n/a
#2: Nov 13 '05

re: SelStart in Large Textbox


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" <oren@gdblegal.com> wrote in message
news:1115918989.844842.76410@g14g2000cwa.googlegro ups.com...[color=blue]
> 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
>[/color]

Oren
Guest
 
Posts: n/a
#3: Nov 13 '05

re: SelStart in Large Textbox


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:[color=blue]
> 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:
>
>[/color]
http://groups-beta.google.com/group/...s.formscoding/[color=blue]
>[/color]
browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E[color=blue]
> CKANKAR&rnum=5&hl=en#5ce723032a342049
>
> Post back if you need some help with the API declarations.
>[/color]

Oren
Guest
 
Posts: n/a
#4: Nov 13 '05

re: SelStart in Large Textbox


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:[color=blue]
> 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:
>
>[/color]
http://groups-beta.google.com/group/...s.formscoding/[color=blue]
>[/color]
browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E[color=blue]
> CKANKAR&rnum=5&hl=en#5ce723032a342049
>
> Post back if you need some help with the API declarations.
>[/color]

Stephen Lebans
Guest
 
Posts: n/a
#5: Nov 13 '05

re: SelStart in Large Textbox


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" <oren@gdblegal.com> wrote in message
news:1116350967.273267.210000@z14g2000cwz.googlegr oups.com...[color=blue]
> Hi Stephen,
>
> Thanks for your advice. Have been under the weather, and so the[/color]
project[color=blue]
> I'm working on was on hold...
>
> Please give some tips regarding the API declarations. How to find[/color]
where[color=blue]
> the cursor is in the textbox and how to set this value when it's[/color]
beyond[color=blue]
> the 32767th character.
>
> All the best,
> Oren
> -------------
>
> Stephen Lebans wrote:[color=green]
> > 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:
> >
> >[/color]
>[/color]
http://groups-beta.google.com/group/...s.formscoding/[color=blue][color=green]
> >[/color]
>[/color]
browse_frm/thread/ebd71aa8ff5b320a/5ce723032a342049?q=lebans+selstart+-E[color=blue][color=green]
> > CKANKAR&rnum=5&hl=en#5ce723032a342049
> >
> > Post back if you need some help with the API declarations.
> >[/color]
>[/color]

Oren
Guest
 
Posts: n/a
#6: Nov 13 '05

re: SelStart in Large Textbox


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

Stephen Lebans
Guest
 
Posts: n/a
#7: Nov 13 '05

re: SelStart in Large Textbox


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" <oren@gdblegal.com> wrote in message
news:1116609410.331741.220920@g49g2000cwa.googlegr oups.com...[color=blue]
> 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
>[/color]

Closed Thread


Similar Microsoft Access / VBA bytes