IonicWind Software

IWBasic => General Questions => Topic started by: Andy on January 21, 2020, 06:31:39 AM

Title: Position in an edit control
Post by: Andy on January 21, 2020, 06:31:39 AM
Can't see anything posted about this, so I'll ask:

If I have and edit control, and in it are some words say...

These are some words

And I place the edit position in front of the word "are", which would be position 7 in the string of these words, how can I get that position i.e. 7?

Can this be done any one?
Any examples you can post please?

Thanks,
Andy.
Title: Re: Position in an edit control
Post by: Brian on January 21, 2020, 07:05:36 AM
Not sure, but does GetCaretPos do the trick?

Brian

On looking, I think it must be this SENDMESSAGE:

https://docs.microsoft.com/en-us/windows/win32/controls/em-getcaretindex

Title: Re: Position in an edit control
Post by: LarryMc on January 21, 2020, 09:19:46 AM
The proper IWB command for finding the 0 based index of the caret in a line is:

CONTROLCMD window | dialog, ID, @EDGETSELECTION, varStart, varEnd

If nothing is selected then varStart=varEnd = 0 based index of caret
Title: Re: Position in an edit control
Post by: Andy on January 21, 2020, 10:08:46 AM
Thanks guys,

Will give it whirl!

Andy.
 :)