首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

登陆密码对话框程序无异常却运行无结果~

2012-12-31 
登陆密码对话框程序无错误却运行无结果~求救!// PasswordDialog.cpp : implementation file//#include st

登陆密码对话框程序无错误却运行无结果~求救!
// PasswordDialog.cpp : implementation file
//

#include "stdafx.h"
#include "E2_1.h"
#include "PasswordDialog.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CPasswordDialog dialog


CPasswordDialog::CPasswordDialog(CWnd* pParent /*=NULL*/)
: CDialog(CPasswordDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CPasswordDialog)
m_Password = 0;
//}}AFX_DATA_INIT
}


void CPasswordDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPasswordDialog)
DDX_Control(pDX, IDC_PASSWORD_EDIT, m_Edit1);
DDX_Text(pDX, IDC_PASSWORD_EDIT, m_Password);
DDV_MinMaxInt(pDX, m_Password, 0, 9999);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPasswordDialog, CDialog)
//{{AFX_MSG_MAP(CPasswordDialog)
ON_EN_CHANGE(IDC_PASSWORD_EDIT, OnChangePasswordEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPasswordDialog message handlers

void CPasswordDialog::OnChangePasswordEdit() 
 {
 // TODO: If this is a RICHEDIT control, the control will not
 // send this notification unless you override the CDialog::OnInitDialog()
 // function and call CRichEditCtrl().SetEventMask()
 // with the ENM_CHANGE flag ORed into the mask.

 // TODO: Add your control notification handler code here
 CString temp;
 int length1;
 BOOL length2;
 length1 = m_Edit1.GetWindowTextLength();   //获取输入的字符个数
if(length1 == 4)                           //如果输入的是4个字符
{
m_Edit1.GetWindowText(temp);           //获取文本框中的全部字符
length2 = temp.Find("1925");
 if(length2!=0)                         //检查输入的字符是否指定的口令
{
CString p1=_T("Password Wrong!");   
     CString p2=_T("ERROR");
 
MessageBox(p1,p2,MB_ICONERROR);
 }
 }
 } 
[解决办法]
length2 = temp.Find("1925");当找到1925时返回值为0.所以你应该 if(length2==0)
[解决办法]
CString strTemp;
m_Edit1.GetWindowText(strTemp);
if (0 != strTemp.Compare(_T("1925")))
{
CString p1=_T("Password Wrong!");   
CString p2=_T("ERROR");

MessageBox(p1,p2,MB_ICONERROR);
}

热点排行