views:

846

answers:

1

Hi,

I am using VC9, I've a CEdit control whose contents are reset to default test (say - "fill-in") at the click of a button and then i call SetFocus for the CEdit control. The problem is that the cursor blinks at the start of the default text, and i want it to blink an the end of the default string.

How can this be done?

+3  A: 

You can use CEdit::SetSel to accomplish that.

Example:

CEdit* e = (CEdit*)GetDlgItem(IDC_EDIT1);
e->SetWindowText("hello world");
e->SetFocus();
e->SetSel(0,-1); // select all text and move cursor at the end
e->SetSel(-1); //  remove selection
Nick D
thanks, that fixed it :)