How to set caret position in Edit Control?
-
Hello and thanks for looking at my problem, I want to both select some text and set the caret postion in a edit control as if the user clicked the mouse at the end of the text and then draws the mouse pointer towards the beginning of the text. When doing so, the caret position is somewhere in the middle of the text and everything behind it is selected, like this: this is |some text where the bold stuff is selected and the caret is the "|". EM_SETSEL always results in selected text with the caret at its end, like this: this is some text| but I need the caret at the beginning. Does anyone know how to do? Thanks a lot... Martin Hoppe
-
Hello and thanks for looking at my problem, I want to both select some text and set the caret postion in a edit control as if the user clicked the mouse at the end of the text and then draws the mouse pointer towards the beginning of the text. When doing so, the caret position is somewhere in the middle of the text and everything behind it is selected, like this: this is |some text where the bold stuff is selected and the caret is the "|". EM_SETSEL always results in selected text with the caret at its end, like this: this is some text| but I need the caret at the beginning. Does anyone know how to do? Thanks a lot... Martin Hoppe
Reverse the starting and ending position arguments: pCtrl->SendMessage( EM_SETSEL, // message to send (WPARAM) 10, // starting position (LPARAM) 5 // ending position (caret postion) ); INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
Hello and thanks for looking at my problem, I want to both select some text and set the caret postion in a edit control as if the user clicked the mouse at the end of the text and then draws the mouse pointer towards the beginning of the text. When doing so, the caret position is somewhere in the middle of the text and everything behind it is selected, like this: this is |some text where the bold stuff is selected and the caret is the "|". EM_SETSEL always results in selected text with the caret at its end, like this: this is some text| but I need the caret at the beginning. Does anyone know how to do? Thanks a lot... Martin Hoppe
What about using EM_SETSEL with the beginning and the end at the same position? Don't try it, just do it! ;-)
-
Reverse the starting and ending position arguments: pCtrl->SendMessage( EM_SETSEL, // message to send (WPARAM) 10, // starting position (LPARAM) 5 // ending position (caret postion) ); INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
Thanks a lot for your answer, Andrew! Unfortunately I already tried that, but does NOT work. But maybe this is because I am on Embedded C++ 4.0? At least I am sure it does NOT work in Embedded C++ 4.0, but I will have a look in C++ 6.0 too. Do you or anyone have a solution for eMbedded C++, too?. Thank you very much... Martin