Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem getting edit box value in a Modal Dialog

mcmxxxmcmxxx Member Posts: 5
[italic]Hello Everyone,

I'm not familiar with the Visual C++, so would really appreciate help from you guys.

From Dialog A (Class A), I have a button that will open Dialog B (Class B). Dialog B has an edit box and the value in this editbox I need to verify when I press the OK button of Dialog B. Unfortunately, I can't get the value. Below is part of my code.[/italic]


#include "stdafx.h"
#include "ClassA.h"
#include "ClassB.h"

BOOL CClassA::OnButtonA()
{
CDialog aboutDlg(IDD_DIALOG_B);
int nRet = -1;
nRet = aboutDlg.DoModal();
aboutDlg.SetActiveWindow();

switch (nRet)
{
case -1:
AfxMessageBox("Dialog box could not be created!");
break;
case IDOK:
{
CString checkValue;
CClassB getValue;
checkValue = getValue.GetPasswordValue();
MessageBox(checkValue, "Get Password Value", MB_OK);
break;
}

case IDCANCEL:
break;

default:
break;
}
}

*************************

#include "stdafx.h"
#include "adstoolkit.h"
#include "ClassB.h"

// CClassB dialog

CClassB::CClassB(CWnd* pParent /*=NULL*/)
: CDialog(CClassB::IDD, pParent)
{
//{{AFX_DATA_INIT(CEngVerifyPassword)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}


void CEngVerifyPassword::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEngVerifyPassword)
DDX_Text(pDX, IDC_EDIT_PASSWORD, m_editPassword);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CClassB, CDialog)
//{{AFX_MSG_MAP(CEngVerifyPassword)
ON_BN_CLICKED(IDCANCEL, OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


// CClassB message handlers
BOOL CClassB::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}

void CClassB::OnCancel()
{
CDialog::OnCancel();
}

void CCClassB::OnOK()
{
CDialog::OnOK();
}

CString CClassB::GetPasswordValue()
{
return m_editPassword;
}

[italic]I can't get the value at edit box IDC_EDIT_PASSWORD (m_editPassword). Any idea what seems to be the problem...

Thank you very much,
maria[/italic]
Sign In or Register to comment.