0

file DoAnMFC.h

public:
    CString user;
    CString pass;
    bool isAdmin;
    bool isLogin;
    afx_msg void OnBnClickedLoginBtn();
    afx_msg void OnBnClickedCancleBtn();
    afx_msg void showwithAdmin();
    afx_msg void showwithEmployee();
    afx_msg void ghiLog();
    afx_msg bool CheckLogin(CString username,CString password);
    CListCtrl m_ListControl;
    CEdit m_EditControl;
    afx_msg void OnSystemChangepassword();
    afx_msg void OnSystemExit();
    afx_msg void OnToolsCreateaccount();
    afx_msg void OnToolsEditaccount();
    afx_msg void OnToolsFindaccount();
    afx_msg void OnToolsDeleteaccount();
    CEdit m_ControlUser;
    CEdit m_ControlPassword;

This is event click a button to change Password

void ChangePassword::OnBnClickedOkBtn()
    {
        UpdateData(true);
        CDoAnMFCDlg d;
        CString loginPassword;
        d.m_ControlPassword.GetWindowText(loginPassword);
        if( d.pass.Compare(loginPassword)==0 && m_NewPassword.Compare(m_ConfirmPassword)==0 )
            {...........}
    }

How to compare data form ChangePassword with data from form DoAnFMC ? This line have result is false

d.pass.Compare(loginPassword)==0
KayTran
  • 11
  • 4
  • You can't use just *any* dialog object to get the value, you must use the exact dialog object that was shown to the user. And it must still be active, or the call will fail. – Mark Ransom Dec 03 '14 at 16:38
  • How i can use variable "pass" in form ChangePassword ? – KayTran Dec 03 '14 at 16:51
  • 1
    Your understanding of how things work is so far off that I'm not sure I can help you. – Mark Ransom Dec 03 '14 at 17:02
  • There is no example. The proper way to do things is from within the active dialog itself, or from a dialog that you created locally after `DoModal` has returned `ID_OK`. To get a value from one dialog into another completely disassociated dialog is not something people usually do. – Mark Ransom Dec 03 '14 at 17:48
  • It working fine in my system, I think you are not getting value of CString `pass`. Try to print value of `d.pass` in a message box. – Himanshu Dec 04 '14 at 04:26
  • possible duplicate of [Why i can't compare CString in MFC](http://stackoverflow.com/questions/27273176/why-i-cant-compare-cstring-in-mfc) – Werner Henze Dec 11 '14 at 14:31

0 Answers0