SetCursorPos and GetWindowText
-
Hi, I am a newbie in MFC gui programming. Here is one problem that I am facing.. I am setting text in an edit control and then i need to set the cursor at the end of the text. If I use SetEditSel, it highlights the text also. I do not want the highlighting of the text. I just want the cursor to be at the end of the text ,after I have called SetWindowText(). I searched around and found that SetCursorPos can help. But I do not know how to provide the correct text coordinates to this API. any ideas would be greatly appreciated. Code snippet: InSomeHandler(){ GetWindowText(str); // do something SetWindowText(str); // set the cursor at the end: don't know how to do it.. } Be the change you wish to see...
-
Hi, I am a newbie in MFC gui programming. Here is one problem that I am facing.. I am setting text in an edit control and then i need to set the cursor at the end of the text. If I use SetEditSel, it highlights the text also. I do not want the highlighting of the text. I just want the cursor to be at the end of the text ,after I have called SetWindowText(). I searched around and found that SetCursorPos can help. But I do not know how to provide the correct text coordinates to this API. any ideas would be greatly appreciated. Code snippet: InSomeHandler(){ GetWindowText(str); // do something SetWindowText(str); // set the cursor at the end: don't know how to do it.. } Be the change you wish to see...
You can use
SetSel
for this. I assume you're using aCEdit
control. Let's say this control is accessed through a member variable calledm_edit
and contains the textstr
, you can then set the cursor to the end of the control by calling this:m_edit.SetSel(str.GetLength(), 0, FALSE);
Too many passwords to remember? Try KeePass Password Safe!