Solved

password help!

Posted on 2000-02-15
6
201 Views
Last Modified: 2010-04-02
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
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2526225
As a starter, you can set a style on the edit box to be Password (so every character typed is shown as a star).

Secondly, you should call GetWindowText(...) on either edit box to see what has been typed.

And finally, we don't do homework.
0
 
LVL 1

Accepted Solution

by:
mahno earned 50 total points
ID: 2526441
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
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2526482
Well at least I thought we didn't do homework!
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

by:mahno
ID: 2526631
Sorry, ScottyDawg :(
Next time I'll allow for you words

mahno
0
 
LVL 1

Expert Comment

by:ScottyDawg
ID: 2526636
;-)
0
 
LVL 22

Expert Comment

by:nietod
ID: 2526675
Does this sound like homework?  Most introductory courses don't cover windows programming.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now