Select text backwards - so that the current cursor is at the beginning of the selected text.
Posted on 2003-10-30
-- VB6 --
I have the need to select text in a ComboBox so that after selecting the text, the current cursor location is at the front of the selection as opposed to the end of the selection.
The ComboBox has the SelStart and SelLength properties. The SelLength must be 0 or greater (therefore I cannot select a negative length to make the selection go backwards).
I tried sending the CB_SETEDITSEL message to the ComboBox but it would always select the 19th character to the end of line no matter what I passed as a W and L Param. I did put the start and end in the LParam.
I tried getting the handle of the Edit Control associated with the ComboBox and sending the EM_SETSEL message to it. I had a little more success in that I could get it to select the range but it would always put the cursor at the end of the selection. I tried sending a start char of 3 and end char of 7 - and it acted correct. I tried sending a start char of 7 and end char of 3 - and it acted the same as 3 and 7 in that it hilited the correct text but still put the cursor at the end of the selection.