Detect where clicked in text Box

kirkm

Registered User.
Local time
Tomorrow, 02:57
Joined
Oct 30, 2008
Messages
1,257
Can I use any text box event to find what row or where I've clicked?
My aim is to extract some words from the line of text I click on.
Thanks for any help
 
No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).
I didn't think it would be easy!
What it some of the text was selected ? Would that be possible ?
 
If you used .selstart as the starting point, could you not look for a CR/LF and then select everything in between.?

Lot of work for just a drag of a mouse I would have thought though.?
What if you wanted two lines.?
How you you copy the text, button?, that is an extra click as well.?

No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).
I didn't think it would be easy!
What it some of the text was selected ? Would that be possible ?
 
No, the text box has an unknown number of lines, some wrapped (possibly) and a vertical scrollbar. I was hoping to find which line I'd clicked onto, and from there capture some text from that line. (It is a known format for each line).

Sounds like the lines should be being treated as different pieces of data.

Having said that, the Mouse Down Event returns the X and Y coordinates of the click. You can compare this with the font size and the Top and Left of the textbox to determine what line you are on.

I don't think Access has anything to handle the possibility of it being scrolled though. Might be something in Windows API that could return how far down it is since Windows needs to display the scroll bar in the right position.

Many years ago I posted something on here about calculating the heights of text from the font size. I don't recall the details.
 
Thanks for the replies. I learned something quite useful... looking at .SelStart I found .SelText which does exactly what's required - returning the selected text via MouseUp.
.
 
Ah, then I wasn't that far off after all. Glad I pointed you there.
 

Users who are viewing this thread

Back
Top Bottom