Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. where am i mistaking here?

where am i mistaking here?

Scheduled Pinned Locked Moved C / C++ / MFC
windows-adminquestionannouncement
4 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Natural_Demon
    wrote on last edited by
    #1

    BOOL Cfirstw32mfcApp::InitInstance() { SetRegistryKey(_T("Natural_Demon")); ... .. .. } this works perfect ... the data retrieved from the registry is nicely update in the GUI BOOL Cfirstw32mfcDlg::OnInitDialog() { .. ... ... .. EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login"); EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here.."); return FALSE; // return TRUE unless you set the focus to a control } this works perfectly ... HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/) { AfxGetApp()->WriteProfileString("Settings", "email", "hi"); AfxGetApp()->WriteProfileString("Settings", "password", "do"); return NULL; } but why doesn't this work ...? HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/) { UpdateData(FALSE); AfxGetApp()->WriteProfileString("Settings", "email", EDIT1); AfxGetApp()->WriteProfileString("Settings", "password", EDIT2); return NULL; } if i do this ... UpdateData();, UpdateData(FALSE); or this UpdateDialogControls(this, FALSE); nothing works EDIT1 en EDIT2 are empty and the registry get's updated with empty values. where am i mistaking here? thnx in advance. kind regards, marco

    B 1 Reply Last reply
    0
    • N Natural_Demon

      BOOL Cfirstw32mfcApp::InitInstance() { SetRegistryKey(_T("Natural_Demon")); ... .. .. } this works perfect ... the data retrieved from the registry is nicely update in the GUI BOOL Cfirstw32mfcDlg::OnInitDialog() { .. ... ... .. EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login"); EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here.."); return FALSE; // return TRUE unless you set the focus to a control } this works perfectly ... HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/) { AfxGetApp()->WriteProfileString("Settings", "email", "hi"); AfxGetApp()->WriteProfileString("Settings", "password", "do"); return NULL; } but why doesn't this work ...? HRESULT Cfirstw32mfcDlg::OnButtonOK(IHTMLElement* /*pElement*/) { UpdateData(FALSE); AfxGetApp()->WriteProfileString("Settings", "email", EDIT1); AfxGetApp()->WriteProfileString("Settings", "password", EDIT2); return NULL; } if i do this ... UpdateData();, UpdateData(FALSE); or this UpdateDialogControls(this, FALSE); nothing works EDIT1 en EDIT2 are empty and the registry get's updated with empty values. where am i mistaking here? thnx in advance. kind regards, marco

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      Your Data Exchange handler function might not be set up correctly. The Data Exchange might be overwriting the data in your edit field controls, or no member variables are setup to write into the controls. It looks like you fill them in OnInitDialog, but you should do that in DoDataExchange.

      N 1 Reply Last reply
      0
      • B Blake Miller

        Your Data Exchange handler function might not be set up correctly. The Data Exchange might be overwriting the data in your edit field controls, or no member variables are setup to write into the controls. It looks like you fill them in OnInitDialog, but you should do that in DoDataExchange.

        N Offline
        N Offline
        Natural_Demon
        wrote on last edited by
        #3

        this is what i got and all those intents u see in code don't work thank for your time and kind regards, marco // 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 OnChangeEdit1(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(); }; ----------------------------------------------- // firstw32mfcDlg.cpp : implementation file // #include "stdafx.h" #include "firstw32mfc.h" #include "firstw32mfcDlg.h" #include ".\firstw32mfcdlg.h" //#include //#include #include #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"), OnChangeEdit1 ) //DHTML_EVENT_ONCHANGE(_T("password"), OnEnChangeEdit2 ) END_DHTML_EVENT_MAP() Cfirstw32mfcDlg::Cfirstw32mfcDlg(CWnd* pParent /*=NULL*/) : CDHtmlDialog(Cfirstw32mfcDlg::IDD, Cfirstw32mfcDlg::IDH, pParent) //, m_ED

        B 1 Reply Last reply
        0
        • N Natural_Demon

          this is what i got and all those intents u see in code don't work thank for your time and kind regards, marco // 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 OnChangeEdit1(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(); }; ----------------------------------------------- // firstw32mfcDlg.cpp : implementation file // #include "stdafx.h" #include "firstw32mfc.h" #include "firstw32mfcDlg.h" #include ".\firstw32mfcdlg.h" //#include //#include #include #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"), OnChangeEdit1 ) //DHTML_EVENT_ONCHANGE(_T("password"), OnEnChangeEdit2 ) END_DHTML_EVENT_MAP() Cfirstw32mfcDlg::Cfirstw32mfcDlg(CWnd* pParent /*=NULL*/) : CDHtmlDialog(Cfirstw32mfcDlg::IDD, Cfirstw32mfcDlg::IDH, pParent) //, m_ED

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          You should be able to do all your data sets and retrievals within the DoDataExchange similar to something like this: void Cfirstw32mfcDlg::DoDataExchange(CDataExchange* pDX) { CDHtmlDialog::DoDataExchange(pDX); // data TO controls, means LOAD strings with your existing data or default values // you need to do this BEFORE the DDX_DHtml_ElementInnerText calls if( !pDX->m_bSaveAndValidate ){ EDIT1 = AfxGetApp()->GetProfileString("Settings", "email", "your login"); EDIT2 = AfxGetApp()->GetProfileString("Settings", "password", "details here.."); } // these calls presumably set or get the data from the controls into your string variables DDX_DHtml_ElementInnerText(pDX, _T("email"), EDIT1); DDX_DHtml_ElementInnerText(pDX, _T("password"), EDIT2); DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text1"), m_EDIT1); DDX_DHtml_ElementInnerText(pDX, _T("Temp_Text2"), m_EDIT2); // data FROM controls, means SAVE data from the controls to your storage // you need to do this AFTER the DDX_DHtml_ElementInnerText calls if( pDX->m_bSaveAndValidate ){ GetElementText(_T("email")); AfxGetApp()->WriteProfileString("Settings", "email", EDIT1); GetElementText(_T("password")); AfxGetApp()->WriteProfileString("Settings", "password", EDIT2); } } If the DoDataExchange is correctly implemented, you don't even need to have the OnOK handler, since the DoDataExchange will be called for you (I am pretty sure) and you definitely don't need the Cancel, because the UpdatData (and thus DoDataExchange) is not called at all.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups