it fails to retrieve fresh userinput

G

Guest

it fails to retrieve newly intruduced data by the user.

i tried this ...
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
UpdateData(FALSE);

and this..
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}

i tried many combination and searching answer, but i can't find one right.

this is qwhat i do on init

BOOL Cfirstw32mfcDlg::OnInitDialog()
{
...
...
...
....

EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details
here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}

EDIT1 and EDIT2 contain values, either from the register or the alternative
'default value'and it wil be displayed in the userinterface
it's also visible in the userinterface, but if i intruduce values manualy
and press ok,
'UpdateData(FALSE);' doesn't update anything, nor
UpdateData();,UpdateData(TRUE); or UpdateDialogControls(this, FALSE);
i tried resting the values as u can see, but than the entries in the
registry are also empty

what am i doing wrong here

thanx for your time and kind regards,

marco


// firstw32mfcDlg.cpp : implementation file
//

#include "stdafx.h"
#include "firstw32mfc.h"
#include "firstw32mfcDlg.h"
#include ".\firstw32mfcdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
enum { IDD = IDD_ABOUTBOX };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation
protected:
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// Cfirstw32mfcDlg dialog

BEGIN_DHTML_EVENT_MAP(Cfirstw32mfcDlg)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
DHTML_EVENT_ONCHANGE(_T("email"), OnEnChangeEdit1 )
DHTML_EVENT_ONCHANGE(_T("password"), OnEnChangeEdit2 )
END_DHTML_EVENT_MAP()


Cfirstw32mfcDlg::Cfirstw32mfcDlg(CWnd* pParent /*=NULL*/)
: CDHtmlDialog(Cfirstw32mfcDlg::IDD, Cfirstw32mfcDlg::IDH, pParent)
//, m_EDIT1(0)
//, m_EDIT2(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void Cfirstw32mfcDlg::DoDataExchange(CDataExchange* pDX)
{
CDHtmlDialog::DoDataExchange(pDX);
DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text1"), m_EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text2"), m_EDIT2);
}



BEGIN_MESSAGE_MAP(Cfirstw32mfcDlg, CDHtmlDialog)
ON_WM_SYSCOMMAND()
//}}AFX_MSG_MAP
//ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
//ON_EN_CHANGE(IDC_EDIT2, OnEnChangeEdit2)
END_MESSAGE_MAP()


// Cfirstw32mfcDlg message handlers

BOOL Cfirstw32mfcDlg::OnInitDialog()
{
CDHtmlDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//EDIT1=("");
//EDIT2=("");
EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details
here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}

void Cfirstw32mfcDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDHtmlDialog::OnSysCommand(nID, lParam);
}
}

void Cfirstw32mfcDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()),
0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDHtmlDialog::OnPaint();
}
}

// The system calls this function to obtain the cursor to display while the
user drags
// the minimized window.
HCURSOR Cfirstw32mfcDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();

//AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
//AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
//OnOK();
//return S_OK;
return NULL;
}

HRESULT Cfirstw32mfcDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
{
GetElementText(_T("email"));
if(GetElementText(_T("email")))
{
EDIT1=_T("works");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();
return S_OK;
//return 0;
}
HRESULT Cfirstw32mfcDlg::OnEnChangeEdit1(IHTMLElement* /*pElement*/)
{
//CDHtmlDialog::GetElementText(EDIT1);
//UpdateDialogControls(this, FALSE);
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
return FALSE;
}

HRESULT Cfirstw32mfcDlg::OnEnChangeEdit2(IHTMLElement* /*pElement*/)
{
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
return FALSE;
}



// firstw32mfcDlg.h : header file
//

#pragma once


// Cfirstw32mfcDlg dialog
class Cfirstw32mfcDlg : public CDHtmlDialog
{
// Construction
public:
Cfirstw32mfcDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
enum { IDD = IDD_FIRSTW32MFC_DIALOG, IDH = IDR_HTML_FIRSTW32MFC_DIALOG };
CString EDIT1;
CString EDIT2;
CString m_EDIT1;
CString m_EDIT2;
CString m_TEMP_EDIT1;
CString m_TEMP_EDIT2;

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
HRESULT OnEnChangeEdit1(IHTMLElement *pElement);
HRESULT OnEnChangeEdit2(IHTMLElement *pElement);

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
DECLARE_DHTML_EVENT_MAP()
public:
//char m_EDIT1;
//char m_EDIT2;
//afx_msg void OnEnChangeEdit1();
//afx_msg void OnEnChangeEdit2();
};
 
G

Guest

it fails to retrieve newly intruduced data by the user.

i tried this ...
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
UpdateData(FALSE);

and this..
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}

i tried many combination and searching answer, but i can't find one right.

this is qwhat i do on init

BOOL Cfirstw32mfcDlg::OnInitDialog()
{
...
...
...
....

EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details
here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}

EDIT1 and EDIT2 contain values, either from the register or the alternative
'default value'and it wil be displayed in the userinterface
it's also visible in the userinterface, but if i intruduce values manualy
and press ok,
'UpdateData(FALSE);' doesn't update anything, nor
UpdateData();,UpdateData(TRUE); or UpdateDialogControls(this, FALSE);
i tried resting the values as u can see, but than the entries in the
registry are also empty

what am i doing wrong here

thanx for your time and kind regards,

marco


// firstw32mfcDlg.cpp : implementation file
//

#include "stdafx.h"
#include "firstw32mfc.h"
#include "firstw32mfcDlg.h"
#include ".\firstw32mfcdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
enum { IDD = IDD_ABOUTBOX };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

// Implementation
protected:
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// Cfirstw32mfcDlg dialog

BEGIN_DHTML_EVENT_MAP(Cfirstw32mfcDlg)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
DHTML_EVENT_ONCHANGE(_T("email"), OnEnChangeEdit1 )
DHTML_EVENT_ONCHANGE(_T("password"), OnEnChangeEdit2 )
END_DHTML_EVENT_MAP()


Cfirstw32mfcDlg::Cfirstw32mfcDlg(CWnd* pParent /*=NULL*/)
: CDHtmlDialog(Cfirstw32mfcDlg::IDD, Cfirstw32mfcDlg::IDH, pParent)
//, m_EDIT1(0)
//, m_EDIT2(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void Cfirstw32mfcDlg::DoDataExchange(CDataExchange* pDX)
{
CDHtmlDialog::DoDataExchange(pDX);
DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text1"), m_EDIT2);
DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text2"), m_EDIT2);
}



BEGIN_MESSAGE_MAP(Cfirstw32mfcDlg, CDHtmlDialog)
ON_WM_SYSCOMMAND()
//}}AFX_MSG_MAP
//ON_EN_CHANGE(IDC_EDIT1, OnEnChangeEdit1)
//ON_EN_CHANGE(IDC_EDIT2, OnEnChangeEdit2)
END_MESSAGE_MAP()


// Cfirstw32mfcDlg message handlers

BOOL Cfirstw32mfcDlg::OnInitDialog()
{
CDHtmlDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//EDIT1=("");
//EDIT2=("");
EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login");
EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details
here..");
UpdateData(FALSE);
//EDIT1=("");
//EDIT2=("");
UpdateData(FALSE);
return FALSE; // return TRUE unless you set the focus to a control
}

void Cfirstw32mfcDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDHtmlDialog::OnSysCommand(nID, lParam);
}
}

void Cfirstw32mfcDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()),
0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDHtmlDialog::OnPaint();
}
}

// The system calls this function to obtain the cursor to display while the
user drags
// the minimized window.
HCURSOR Cfirstw32mfcDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/)
{
CDHtmlDialog::GetElementText(_T("email"));
if(CDHtmlDialog::GetElementText(_T("email")))
{
EDIT1=_T("works");
}
else
{
EDIT1=_T("it doesn't work");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();

//AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
//AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
//OnOK();
//return S_OK;
return NULL;
}

HRESULT Cfirstw32mfcDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
{
GetElementText(_T("email"));
if(GetElementText(_T("email")))
{
EDIT1=_T("works");
}
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
GetElementText(_T("password"));
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
OnCancel();
return S_OK;
//return 0;
}
HRESULT Cfirstw32mfcDlg::OnEnChangeEdit1(IHTMLElement* /*pElement*/)
{
//CDHtmlDialog::GetElementText(EDIT1);
//UpdateDialogControls(this, FALSE);
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "email", EDIT1);
return FALSE;
}

HRESULT Cfirstw32mfcDlg::OnEnChangeEdit2(IHTMLElement* /*pElement*/)
{
//UpdateData(FALSE);
AfxGetApp()->WriteProfileString("Settings", "password", EDIT2);
return FALSE;
}



// firstw32mfcDlg.h : header file
//

#pragma once


// Cfirstw32mfcDlg dialog
class Cfirstw32mfcDlg : public CDHtmlDialog
{
// Construction
public:
Cfirstw32mfcDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
enum { IDD = IDD_FIRSTW32MFC_DIALOG, IDH = IDR_HTML_FIRSTW32MFC_DIALOG };
CString EDIT1;
CString EDIT2;
CString m_EDIT1;
CString m_EDIT2;
CString m_TEMP_EDIT1;
CString m_TEMP_EDIT2;

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
HRESULT OnEnChangeEdit1(IHTMLElement *pElement);
HRESULT OnEnChangeEdit2(IHTMLElement *pElement);

// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
DECLARE_DHTML_EVENT_MAP()
public:
//char m_EDIT1;
//char m_EDIT2;
//afx_msg void OnEnChangeEdit1();
//afx_msg void OnEnChangeEdit2();
};

User submitted from AEWNET (http://www.aewnet.com/)
 
G

Guest

try

DDX_DHtml_ElementValue(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementValue(pDX, _T("password"), EDIT1);

instead of

DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2);

regards,

(e-mail address removed)

User submitted from AEWNET (http://www.aewnet.com/)
 
G

Guest

try

DDX_DHtml_ElementValue(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementValue(pDX, _T("password"), EDIT1);

instead of

DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1);
DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2);

regards,

(e-mail address removed)

User submitted from AEWNET (http://www.aewnet.com/)
 
G

Guest

thank, that was it.
but i payed someone to find out.
grrr
u came too late, but stil
thanks
it's hard to find someone of knowledge with html userinterfaces.
thnx and kind regards

marco
 
Top