class='cKeyword'>#include "stdafx.h"
class='cKeyword'>#include "guiwin32.h"
class='cKeyword'>#include "UserInputDialog.h"
class='cKeyword'>class='cKeyword'>#ifdef _DEBUG
class='cKeyword'>#define new DEBUG_NEW
class='cKeyword'>#undef THIS_FILE
static class='cKeyword'>char THIS_FILE[] = __FILE__;
class='cKeyword'>#endif
int ForceChgPwd = 0;
UserInputDialog::UserInputDialog(int forceChg, CWnd* pParent )
: CDialog(UserInputDialog::IDD, pParent)
{
ForceChgPwd = forceChg;
m_UserInput = _T("");
m_ChangePassword = FALSE;
m_newPwd = _T("");
}
void UserInputDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_BOX, m_UserInput);
DDX_Check(pDX, IDD_CHANGE_PWD, m_ChangePassword);
DDX_Text(pDX, IDC_CHANGE, m_newPwd);
}
BEGIN_MESSAGE_MAP(UserInputDialog, CDialog)
ON_BN_CLICKED(IDD_CHANGE_PWD, OnChangePwd)
END_MESSAGE_MAP()
void UserInputDialog::OnChangePwd()
{
if ( ((CButton*)GetDlgItem( IDD_CHANGE_PWD ))->GetCheck() == 1 )
{
((CWnd*)GetDlgItem( IDC_CHANGE ))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_CONFIRM))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_NEW_PWD_LABEL))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_CONFIRM_LABEL))->EnableWindow(TRUE);
}
else
{
((CWnd*)GetDlgItem( IDC_CHANGE ))->EnableWindow(FALSE);
((CWnd*)GetDlgItem( IDC_CHANGE ))->SetWindowText("");
((CWnd*)GetDlgItem( IDC_CONFIRM))->EnableWindow(FALSE);
((CWnd*)GetDlgItem( IDC_CONFIRM))->SetWindowText("");
((CWnd*)GetDlgItem( IDC_NEW_PWD_LABEL))->EnableWindow(FALSE);
((CWnd*)GetDlgItem( IDC_CONFIRM_LABEL))->EnableWindow(FALSE);
}
OnPaint();
}
void UserInputDialog::OnOK()
{
CString confirm,errTitle,errMsg;
if ( ((CButton*)GetDlgItem( IDD_CHANGE_PWD ))->GetCheck() == 1 )
{
m_ChangePassword = TRUE;
}
else
{
m_ChangePassword = FALSE;
}
if ( m_ChangePassword == TRUE )
{
((CWnd*)GetDlgItem( IDC_CHANGE ))->GetWindowText( m_newPwd );
((CWnd*)GetDlgItem( IDC_CONFIRM ))->GetWindowText( confirm );
if ( confirm!=m_newPwd)
{
errTitle.LoadString( IDS_PWD_CHANGED_TITLE );
errMsg.LoadString( IDS_CHANGE_PWD_FAILED_CONFIRM );
MessageBox( errMsg, errTitle, MB_OK | MB_ICONERROR );
return;
}
}
CDialog::OnOK();
}
BOOL UserInputDialog::OnInitDialog()
{
CDialog::OnInitDialog();
if (ForceChgPwd)
{
((CButton*)GetDlgItem( IDD_CHANGE_PWD ))->SetCheck(1);
((CWnd*)GetDlgItem( IDD_CHANGE_PWD ))->EnableWindow(FALSE);
((CWnd*)GetDlgItem( IDC_CHANGE ))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_CONFIRM))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_NEW_PWD_LABEL))->EnableWindow(TRUE);
((CWnd*)GetDlgItem( IDC_CONFIRM_LABEL))->EnableWindow(TRUE);
}
return TRUE;
}