Repositioning a cursor in a control
-
I'm changing the text in a control and I want to reposition the cursor at the end of the text after I display the text. What I'm doing doesn't work! The cursor is always set to the beginging of the text (due to the "SetFocus"). Any ideas? NB: m_CheckNoCtrl is a control to the field! m_CheckNoCtrl.SetWindowText(szTemp); // Paint new text in control m_CheckNoCtrl.SetFocus(); // Set focus to control int ndx = m_CheckNo.GetLength(); // Get the new length SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx);
-
I'm changing the text in a control and I want to reposition the cursor at the end of the text after I display the text. What I'm doing doesn't work! The cursor is always set to the beginging of the text (due to the "SetFocus"). Any ideas? NB: m_CheckNoCtrl is a control to the field! m_CheckNoCtrl.SetWindowText(szTemp); // Paint new text in control m_CheckNoCtrl.SetFocus(); // Set focus to control int ndx = m_CheckNo.GetLength(); // Get the new length SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx);
Hi, for me it works CString sJaya("HELLOPSODPO"); c_numedit.SetWindowText(sJaya); // Paint new text in control c_numedit.SetFocus(); // Set focus to control int ndx = sJaya.GetLength (); c_numedit.SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx); And i see that you are setting with one text and doing a getLength() on another wats that for . Regards, FarPointer -- modified at 11:50 Wednesday 18th January, 2006
-
Hi, for me it works CString sJaya("HELLOPSODPO"); c_numedit.SetWindowText(sJaya); // Paint new text in control c_numedit.SetFocus(); // Set focus to control int ndx = sJaya.GetLength (); c_numedit.SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx); And i see that you are setting with one text and doing a getLength() on another wats that for . Regards, FarPointer -- modified at 11:50 Wednesday 18th January, 2006
The GetLength()is on the variable I set up for the text. However you solve my problem! I changed the SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx); To: m_CheckNoCtrl.SendMessage (EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx); I overlooked specifing the control I was sending the message for! It now works for me too. Thanks!!! :)