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. DDV functions

DDV functions

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 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.
  • D Offline
    D Offline
    Dinesh Ahuja
    wrote on last edited by
    #1

    Hi Everybody, I have a class which is being derived from CDialog class. class CEventDialog : public CDialog { private: CString m_sEventDesc; int m_iHours; int m_iMin; // Other implementation has been removed from the class. }; The deifination for DoDataExchange is as follows: void CEventDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX,IDC_ADDSTRHR,this->m_iHours); DDV_MinMaxInt(pDX,this->m_iHours,1,24); DDX_Text(pDX,IDC_EDITDESC,this->m_sEventDesc); DDV_MaxChars(pDX,this->m_sEventDesc,20); DDX_Text(pDX,IDC_ADDSTRMIN,this->m_iMin); DDV_MinMaxInt(pDX,this->m_iMin,1,59); } The problem which i am facing is that if i enter an invalid value for iMin data variable , the DDV_MinMaxInt function displays a message box without any message in it. How should i display the used defined message in the Message Nox which is being created by DDV_MinMaxInt function? Regards Dinesh

    D 1 Reply Last reply
    0
    • D Dinesh Ahuja

      Hi Everybody, I have a class which is being derived from CDialog class. class CEventDialog : public CDialog { private: CString m_sEventDesc; int m_iHours; int m_iMin; // Other implementation has been removed from the class. }; The deifination for DoDataExchange is as follows: void CEventDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Text(pDX,IDC_ADDSTRHR,this->m_iHours); DDV_MinMaxInt(pDX,this->m_iHours,1,24); DDX_Text(pDX,IDC_EDITDESC,this->m_sEventDesc); DDV_MaxChars(pDX,this->m_sEventDesc,20); DDX_Text(pDX,IDC_ADDSTRMIN,this->m_iMin); DDV_MinMaxInt(pDX,this->m_iMin,1,59); } The problem which i am facing is that if i enter an invalid value for iMin data variable , the DDV_MinMaxInt function displays a message box without any message in it. How should i display the used defined message in the Message Nox which is being created by DDV_MinMaxInt function? Regards Dinesh

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Have you stepped into DDV_MinMaxInt() to see why it is failing to retrieve the text?


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      D 1 Reply Last reply
      0
      • D David Crow

        Have you stepped into DDV_MinMaxInt() to see why it is failing to retrieve the text?


        Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

        D Offline
        D Offline
        Dinesh Ahuja
        wrote on last edited by
        #3

        I did that : DDV_MinMaxInt internally calls _AfxFailMinMaxWithFormat function AFX_STATIC void AFXAPI _AfxFailMinMaxWithFormat(CDataExchange* pDX, long minVal, long maxVal, LPCTSTR lpszFormat, UINT nIDPrompt) { ASSERT(lpszFormat != NULL); if (!pDX->m_bSaveAndValidate) { TRACE0("Warning: initial dialog data is out of range.\n"); return; // don't stop now } TCHAR szMin[32]; TCHAR szMax[32]; wsprintf(szMin, lpszFormat, minVal); wsprintf(szMax, lpszFormat, maxVal); CString prompt; AfxFormatString2(prompt, nIDPrompt, szMin, szMax); AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDPrompt); prompt.Empty(); // exception prep pDX->Fail(); } The prompt variable comes out to be empty. Do I have to explicitly create a String Resource and pass that resource in one of these functions ? Regards Dinesh

        D 1 Reply Last reply
        0
        • D Dinesh Ahuja

          I did that : DDV_MinMaxInt internally calls _AfxFailMinMaxWithFormat function AFX_STATIC void AFXAPI _AfxFailMinMaxWithFormat(CDataExchange* pDX, long minVal, long maxVal, LPCTSTR lpszFormat, UINT nIDPrompt) { ASSERT(lpszFormat != NULL); if (!pDX->m_bSaveAndValidate) { TRACE0("Warning: initial dialog data is out of range.\n"); return; // don't stop now } TCHAR szMin[32]; TCHAR szMax[32]; wsprintf(szMin, lpszFormat, minVal); wsprintf(szMax, lpszFormat, maxVal); CString prompt; AfxFormatString2(prompt, nIDPrompt, szMin, szMax); AfxMessageBox(prompt, MB_ICONEXCLAMATION, nIDPrompt); prompt.Empty(); // exception prep pDX->Fail(); } The prompt variable comes out to be empty. Do I have to explicitly create a String Resource and pass that resource in one of these functions ? Regards Dinesh

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          So what is the value of CEventDialog::iMin, minVal, and maxVal at this point?


          A rich person is not the one who has the most, but the one that needs the least.

          L 1 Reply Last reply
          0
          • D David Crow

            So what is the value of CEventDialog::iMin, minVal, and maxVal at this point?


            A rich person is not the one who has the most, but the one that needs the least.

            L Offline
            L Offline
            Lanka Maheshwar
            wrote on last edited by
            #5

            Hello, You can try the following in the OnInitDialog: CEdit* pEditControl = (CEdit*)GetDlgItem(IDC_EDIT1); if(pEditControl) { pEditControl->SetLimitText(6) ; } Hope this works.. Regards, Maheshwar.

            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