SetSel problem in dialog

Hi,
In my program i got a few edit control box in my dialog. I want when the user click on each edit control box , it will auto highlight the text inside.
After search the forum and msdn i find that SetSel function can done this task. But after i try, it still cannot do what i want to do..

1
2
3
4
5
6
7
8
BEGIN_MESSAGE_MAP(CPropErythemaScore, CPropertyPage)
           ON_CONTROL_RANGE(EN_KILLFOCUS, IDC_dELL0, IDC_dEUL4, OnEditKillFocus)
	   ON_CONTROL_RANGE(EN_SETFOCUS, IDC_dELL0, IDC_dEUL4, OnEditSetFocus)
END_MESSAGE_MAP()

void CTry::OnEditSetFocus(UINT unID){
	((CEdit*)GetDlgItem(unID))->SetSel(0,-1);	
}


any advices?i waiting for your reply..Thank you
Last edited on
If you have the handle to the edit control box, then you can send a message to that to highlight everything:
SendMessage(hwnd, EM_SETSEL, 0, -1);
Where "hwnd" is the handle to your edit control box, usually a handle for an edit control box will be returned from a CreateWindow or CreateWindowEx function:
HWND hwnd=CreateWindow("EDIT", ...);

Hope this helps.
Topic archived. No new replies allowed.