>I need a little help with Ole D&D in a Fox form that needs to embed a marked up file string into a textbox. Scenario is this:
>
>User drags a file from Explorer into my textbox
>File is expanded into an HTML Img tag on drop
>
>I can get the filename and translate it properly using standard OleDrag Drop (OleDragOver to activate, then capture the oDataOjbect in OleDragOver).
>
>Problem is I can't figure out how to drop the data into the text control at the drag and drop cursor position. I have hte text, but how do I get the cursor position or how do I make the Drag and Drop operation automatically drop it there?
>
>What I need is a way to either calculate the cursor position inside of the textbox, or be able to modify the content of the data object so that Fox can automaitcally drop the new text value I've written to it. Problem is the latter also doesn't seem to work as I can't seem to write to the Data object in any of the methods like OleDragDrop.
>
>Anybody have any ideas on how to do this?
>
>+++ Rick ---
Hi Rick,
Hope I didn't missed your Point. Since you expand the drop file yourself (manually), you also have to put the expanded text into the textbox manually <g>
Anyway, you can get the cursor position using the following formula (this is not the real code):
store textbox.left to nLeft, nStart
nPos = 0
Do while (nLeft < nXCoord)
nPos = nPos+1
nLeft = nStart + GetTextWidth( left( This.Value, nPos ) )
enddo
This.Value = left( This.Value, nPos-1 ) + TheString + substr( This.Value, nPos )
If you use Editbox or use a wordwrap textbox, then you must also calculate the font height to get the line number
HTH
Herman