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 do you use a edit box (password) to get to another dialog window?

Status
Not open for further replies.

real

Programmer
Jan 20, 2001
15
US
How do you get to another dialog window, after the correct password is entered into the edit box? Im trying to expand my knowledge on this area. My manuals do not cover this area and I would like to learn it. If anyone can help, it'd be appreciated. thank you, charles
 
I am new to VC++. I use VC++6 and use MFC.

I assume that the 1st dialog is in class CPassDlg.
I assume that the 2nd dialog is in class CWorkDlg.
I also assume that the Edit control does not use a database for storing a password and is named IDC_EDIT_PASS.
I also assume that there is a button on the CPassDlg that verifies the password when clicked named IDC_BTN_PASS.

1. Open the class wizard ( Ctrl+W ).
2. Select CpassDlg.
3. Select tab "Member Variables".
4. Select the control. i.e. IDC_EDIT_PASS
5. Click "Add Variable".
6. In the following dialog, enter the following parameters:

Control ID = IDC_EDIT_PASS
Variable Name = m_editPass
Category = Control
Type = CEdit

7. Use class wizard to add member function that handles BN_CLICKED message for the IDC_BTN_PASS.
8. Name the function "OnBtnPass".
9. Use class wizard to similarly create an OnOK function for your OK button.
10. Go to the function OnBtnPass in your Dialog's Implimentation file and add:

void CPassDlg::OnBtnPass()
{
CString szPassword = "Your Password goes here";
CString szUser;

// This retrieves the value in the Edit Control to a CString variable
m_editPass.GetWindowText( szUser );
if( szUser == szPassword )
{
CWorkDlg dlg; // Creates the new dialog
dlg.DoModal(); // Executes it in Modal format
OnOK(); // Activates the OK button, closing the dialog
}
else
{
AfxMessageBox( "Wrong Password Sherlock Holmes!!" );
}
}

11. Compile and run the program.

I have not tested this. So sorry for any error or bugs. :) Take it Easy :)
Kartik.S
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top