Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding position of cursor within a text / edit window 1

Status
Not open for further replies.

kazl

Programmer
Dec 9, 2002
68
GB
Hi to everybody.

I'm working in Visual FoxPro 6 and am stuck on something that may be quite simple to someone out there...

I want to create a "hot key" function within a text or edit box that can give me the current cursor position. This is so that I can then programatically insert text selected from another source.

I've been through MSDN Help, VFP manuals, various books and searched the Web. All I've found so far is that there's a WGETCURSOR function somewhere in the API Library Routines. I've not used the API Library Routines yet (that I'm aware of!) and don't know where to start.

Have I missed a function somewhere or does anyone know of another option to get the cursor position? If I have to use API - how I would find the correct Library / source?

Any wee pointers would be really appreciated.
Thank you. Kaz

P.S I put this message into Windows API Forum first so sorry to anyone who's now seen this twice.

 
Kaz,
If your cursor is at a given location, then an insert (paste) will take place there, and you don't really need to "know" where the cursor is. Maybe I'm missing something - it seems too easy!

Rick
 
I'm not sure how to retrieve the current cursor position, I've never needed to do that.
However, here are some functions that may be useful, since the cliboard gets put wherever the cursor is:

ON KEY LABEL F12 MyInsert()

FUNCTION MyInsert
_CLIPTEXT = FILETOSTR('MyText.txt')
-or-
_CLIPTEXT = MyTable.SomeField
KEYBOARD '{CTRL+V}'
RETURN .T.

This places the cursor at a given location in a file.
MODIFY FILE MyFile.TXT RANGE 20, 20

Dave S.
 
The current cursor position is stored in the SELSTART property.

Ian
 
I knew it should be simple, it was just made to sound complicated.

The idea is that while typing notes into an edit box the user can press the hot key to browse a "comment bank" and then select an item from the comment bank to pull straight into the edit box at the current cursor position (not always the end of the text).

I've tried the copy and paste method and it doesn't lose the position so that's great.

After learning how to program classes including combo boxes and SQL statements.. it's been a hard week!

Thank you very much. Kaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top