Solved

password help!

Posted on 2000-02-15
1
194 Views
Last Modified: 2010-04-10
I am a beginner in Visual C++. I need some help urgently. I have two edit boxes in a dialog box. Also there is an OK and CAncel button. In one I am supposed to enter a password and in the other I need to confirm the password(that is I type that password once again). If the two passwords match on pressing the OK button then it is fine, else I need a message box which pops up saying that the passwords entered are not same and that we need to check the two passwords once again. Also, if any of the two boxes are blank we need a message box to say that password needs to be entered. On pressing the Cancel button I should be back in the same window with the fields for password and password confirmation cleared. Could someone please help me with writing this code please.


Could someone help me out on this fast please!
0
Comment
Question by:gopalanravi
1 Comment
 
LVL 1

Accepted Solution

by:
mahno earned 50 total points
ID: 2526081
Hi gopalanravi,

U need to place to dialog form 2 Edit controls an 2 buttons. In Edit control propierties (right mouse buttom click -> propierties) set check "Password". Double click to OK button (with CTRL button pressed) U get:

void CPwdDlg::OnOk()
{
  // TODO: Add your control notification handler code here
}

add code:

  CString szEdit1, szEdit2;

  GetDlgItem(IDC_EDIT1)->GetWindowText(szEdit1);
  GetDlgItem(IDC_EDIT2)->GetWindowText(szEdit2);
 
  if (szEdit1.IsEmpty()) {
    MessageBox("Please enter password");
  } else if (szEdit2.IsEmpty()) {
    MessageBox("Please confirm password");
  } else if (szEdit1 != szEdit2) {
    MessageBox("Password mismatch!");
  } else {
    EndDialog(IDOK);
  }

Double click to Cancel button (with CTRL button pressed) U get:

void CPwdDlg::OnCancel()
{
  // TODO: Add your control notification handler code here
}

add code:
  GetDlgItem(IDC_EDIT1)->SetWindowText("");
  GetDlgItem(IDC_EDIT2)->SetWindowText("");

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question