Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EditBox highlight and focus problem

Status
Not open for further replies.

Mechy

Programmer
Sep 29, 2003
11
US
Hi everybody,

This is supposed to be really easy, but I can't get it to work. All I want to do is to automatically highlight the text in the text box when the user clicks on it. This needs to be just like using tab key.

Here is the procedure I use:

1) Create a text box and assign a control variable to it. (let's say m_cText)
2) I initialize the text in "OnInitDialog" by using

m_cTest.SetWindowText("Test");

3) I create a EN_SETFOCUS handler using class wizard.
4) I enter

m_cTest.SetSel(0,-1);

into the CEditBoxDlg::OnSetfocusEditFocus() function.

When I run the program, it doesn't work. Can you tell me what I am missing?

Thanks.

Mechy
 
Want to post the code, as I am not sure what you are doing with this.

I'd guess that CEditBoxDlg::OnSetfocusEditFocus() is a function in your dialog page, and not the one for your control?

But without seeing the code I can't say.
 
Ok,

The ID of the edit box is IDC_EDIT_FLASH_PASSWORD.

I create a new control (CEdit, not CString) variable for this edit control with Class Wizard named, m_ePassword.

Then I create EN_SETFOCUS function using class wizard and edit the code as follows:

void CFixtureDlg::OnSetfocusEditFlashPassword()
{
// TODO: Add your control notification handler code here
m_ePassword.SetSel(0,-1);
}

This is the procedure I follow. Does this help?

Thank you for your time.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top