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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set a focus

Status
Not open for further replies.

atoledo

Programmer
Oct 14, 2002
16
ES
Hi! I´m a C++ beginner and I would like to know how can I set the focus to a edit box. I´m triying to build a login dialog and I would like to set the focus to the first edit box ( where the user puts his/her login). I tried to use GetDlCtrl and setFocus but no results!

Thanks!
 
>> I tried to use GetDlCtrl and setFocus but no results!

post the relevant code

-pete
 
BOOL ventanita::OnInitDialog()
{
//Recover mthe control ID
CWnd *uWnd = GetDlgItem(IDC_USUARIO1);
// Set the focus
uWnd->SetFocus();
}
 
Did you use the Class Wizard to generate your OnInitDialog() handler? If you did there would be a return statement with a comment following it, like this:

Code:
	return TRUE;  // return TRUE  unless you set the focus to a control

;-)
-pete
 
BOOL ventanita::OnInitDialog()
{

CWnd *uWnd = GetDlgItem(IDC_USUARIO1);
uWnd->SetFocus();

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

yes but it doesn't resolve my problem! :'(
 
oK! thanks! I found the solution THAN YOU VERY MUCH!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top