Re: Win32lib question RE: edit controls
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Mar 15, 2000
- 444 views
SR Williamson wrote: > ... edit control ... Try these; they're more generic and I've had a chance to test them a bit. -- David Cuny global function getSelectedText( integer id ) integer firstPos, lastPos atom result sequence text -- get the range of selected text result = sendMessage( id, EM_GETSEL, NULL, NULL ) firstPos = lo_word( result ) lastPos = hi_word( result ) -- is any text selected? if firstPos < lastPos then -- get all the text text from the mle text = getText( id ) -- get the selected portion of the text return text[firstPos+1..lastPos] else -- no text selected return "" end if end function global procedure setSelectedText( integer id, sequence text ) atom addrText, result -- is there any text selected? result = sendMessage( id, EM_GETSEL, NULL, NULL ) if lo_word( result ) < hi_word( result ) then -- convert to lpsz addrText = allocate_string( text ) -- replace selection; True means allow undo result = sendMessage( id, EM_REPLACESEL, True, addrText ) -- free the string free( addrText ) end if end procedure