Re: [WIN] richedit: how to programmatically select text?
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 17, 2004
- 576 views
danielmoyer wrote: > > > > posted by: Derek Parnell <ddparnell at bigpond.com> > > > > danielmoyer wrote: > > > > > > I tried to select text in a richedit (using Win32Lib 59.1) by using > > > setIndex, & it wouldn't work; is this a bug that's corrected in more > recent > > > versions, or is there an alternate way to programmatically select text > in a > > > richedit control? > > > > Nothing new or fixed here. > > > > setIndex(myRichEdit, {start, stop} ) > > > > What happens when you try? > > > > -- > > Derek Parnell > > Melbourne, Australia > > > > The text between start & stop is not selected (ie, not high-lighted). > > In order to experiment with richedit to see if I could use it, I went into > generic.exw & added an "info" button to the tool bar, & put some text in the > richedit like this: > > setText(GText, "this is a line\nthis is a second line\n" & > "select some text & click the right-most question mark\n" & > "to see the index of start/finish") > > And then in the click on that button event did this: > > > -- richedit info... behavior > procedure onClick_ToolInfo(integer self, integer even, sequence parms) > atom found > > found = findText(GText, "click", 0, findDown + findMatchCase + > findWholeWord) > setIndex(GText, {found, found + length("click")}) > > setText({GStatus,2},"") > setText({GStatus,2},sprint(found)) > > > end procedure > setHandler (ToolInfo, w32HClick, routine_id( "onClick_ToolInfo" )) > > I thought the above should have high-lighted "click" when the button in the > toolbar was clicked on, but while the status bar showed the correct position > of the word, it was not high-lighted. > > Using: > Win98 1st ed, Eu 2.3, Win32Lib 59.1. Either set focus to the richedit before selecting text, or create the richedit control with the ES_NOHIDESEL flag. -- Derek Parnell Melbourne, Australia