Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining row/col pixel position of text cursor in con
Message
From
31/10/2001 09:07:55
 
 
To
30/10/2001 23:07:12
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00575285
Message ID:
00575599
Views:
29
>Jay,
>
>Thanks for your reply. I follow your technique and it works great for single line text. For multi-line (word wrapped) text, its an approximation with varying accuracy - dependent on the text. It also does not take into account the impact of control chars like carriage returns.
>
>I'm going to repost this question in the Windows API forum. Even though VFP does not expose such properties, it seems logical to me that a control must have some way of knowing the physical and relative row and column positions of the text cursor.
>
>Thanks again for your help!
>
>Malcolm

I also wonder if an ActiveX control might offer more access.

Jay

>
>>>Is there a way to determine the row and column pixel position of the text cursor in an input control such as a text box, edit box, or combo box?
>>>
>>>We would like to be able to popup a small 'smart tag' like form in our edit boxes when we detect certain text patterns. Ideally we would like to popup this 'smart tag' like form relative to the position of the text cursor.
>>>
>>>Any help or insights appreciated!
>>>Malcolm
>>
>>For controls which display one row of data, such as a text or combo, you have the control's location. You can use the control's .SelStart property to find out the character position of the cursor, extract the characters up to that point. A combination of TXTWIDTH() (returning the length in characters) and FONTMETRIC(6) (returning the length in pixels) to get a very close approximation.
>>
>>I don't know of a way of determining exactly what row and column position a cursor resides on in an edit box. You can calculate pretty close by using the control's size, and FontMetric. The length in pixels you can approximate with TXTWIDTH and FONTMETRIC (6). For the height you need to factor in the character size as well as regular and special leading (FONTMETRIC (1) + FONTMETRIC (4) + FONTMETRIC (5)).
>>
>>Divide the text width in pixels by the control's width to get the integer line number. Line numbers times height gives the distance from the top of the control. The Mod of the text width dividec by the control's width can be used to provide a percentage of the width to locate your popup.
>>
>>HTH,
>>
>>Jay
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform