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. ATL / WTL / STL
  4. How to override CWinDataExchange

How to override CWinDataExchange

Scheduled Pinned Locked Moved ATL / WTL / STL
tutorialquestion
4 Posts 2 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.
  • P Offline
    P Offline
    paulb
    wrote on last edited by
    #1

    I tried this:

    template class CWinDataExchangeEx :
    public CWinDataExchange
    {
    public:
    // my new DDX functions here...

    Then I have the dialog class is derived from CWinDataExchangeEx. But now none of the base class DDX routines get called anymore, only my new one's in the Ex class?!

    S 1 Reply Last reply
    0
    • P paulb

      I tried this:

      template class CWinDataExchangeEx :
      public CWinDataExchange
      {
      public:
      // my new DDX functions here...

      Then I have the dialog class is derived from CWinDataExchangeEx. But now none of the base class DDX routines get called anymore, only my new one's in the Ex class?!

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      An example of the code that doesn't work as you expect would help...as well as a clear statement of exactly what you expected. If you (for example) added a new overload of DDX_Text, then the definition of DDX_Text in your class will hide the definitions in the base class. To fix this, you'd add the following line to your CWinDataExchangeEx class:

      using CWinDataExchange<T>::DDX_Text;

      P 1 Reply Last reply
      0
      • S Stuart Dootson

        An example of the code that doesn't work as you expect would help...as well as a clear statement of exactly what you expected. If you (for example) added a new overload of DDX_Text, then the definition of DDX_Text in your class will hide the definitions in the base class. To fix this, you'd add the following line to your CWinDataExchangeEx class:

        using CWinDataExchange<T>::DDX_Text;

        P Offline
        P Offline
        paulb
        wrote on last edited by
        #3

        this is my added code (I am trying to implement a DDX_CBSTRING function ala MFC): (in my atlddx2.h)

        namespace WTL
        {

        #define DDX_CBSTRING(nID, var) \
        if(nCtlID == (UINT)-1 || nCtlID == nID) \
        { \
        if(!DDX_CBString(nID, var, sizeof(var), bSaveAndValidate)) \
        return FALSE; \
        }

        template <class T>
        class CWinDataExchangeEx : public CWinDataExchange<T>

        BOOL DDX\_CBString(UINT nID, \_CSTRING\_NS::CString& value, int /\*cbSize\*/, BOOL bSave /\*, BOOL bValidate = FALSE\*, int nLength = 0\*/)
        { // implementation here.....
        
        }
        

        };

        }; // namespace WTL

        then on the dialog class:

        #include "atlddx2.h"

        class CScaleEditDlg :
        public CDialogImpl<CScaleEditDlg>,
        public CWinDataExchangeEx<CScaleEditDlg>
        {
        // .....
        BEGIN_DDX_MAP(CScaleEditDlg)
        DDX_CBSTRING(IDC_SCALE_MODEL, m_strModel)
        DDX_TEXT(IDC_SCALE_DESCRIPTION, m_strDescription)
        DDX_INT_RANGE(IDC_SCALE_SA, m_nStationAddress, 0, 999)
        DDX_CONTROL_HANDLE(IDC_SCALE_IMAGE, m_ctlImage)
        END_DDX_MAP()

        };

        None of the base class DDX routines seem to get called, e.g. DDX_TEXT, DDX_INT_RANGE, etc. I set breakpoints in DDX_Text() and all others but only the DDX_CBString one gets hit. Could it have something to do with the way the macro's are defined? They are defined within a function body: (from atlddx.h)

        // DDX map macros
        #define BEGIN_DDX_MAP(thisClass) \
        BOOL DoDataExchange(BOOL bSaveAndValidate = FALSE, UINT nCtlID = (UINT)-1) \
        { \
        bSaveAndValidate; \
        nCtlID;

        #define DDX_TEXT(nID, var) \
        if(nCtlID == (UINT)-1 || nCtlID == nID) \
        { \
        if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate)) \
        return FALSE; \
        }
        // ....

        S 1 Reply Last reply
        0
        • P paulb

          this is my added code (I am trying to implement a DDX_CBSTRING function ala MFC): (in my atlddx2.h)

          namespace WTL
          {

          #define DDX_CBSTRING(nID, var) \
          if(nCtlID == (UINT)-1 || nCtlID == nID) \
          { \
          if(!DDX_CBString(nID, var, sizeof(var), bSaveAndValidate)) \
          return FALSE; \
          }

          template <class T>
          class CWinDataExchangeEx : public CWinDataExchange<T>

          BOOL DDX\_CBString(UINT nID, \_CSTRING\_NS::CString& value, int /\*cbSize\*/, BOOL bSave /\*, BOOL bValidate = FALSE\*, int nLength = 0\*/)
          { // implementation here.....
          
          }
          

          };

          }; // namespace WTL

          then on the dialog class:

          #include "atlddx2.h"

          class CScaleEditDlg :
          public CDialogImpl<CScaleEditDlg>,
          public CWinDataExchangeEx<CScaleEditDlg>
          {
          // .....
          BEGIN_DDX_MAP(CScaleEditDlg)
          DDX_CBSTRING(IDC_SCALE_MODEL, m_strModel)
          DDX_TEXT(IDC_SCALE_DESCRIPTION, m_strDescription)
          DDX_INT_RANGE(IDC_SCALE_SA, m_nStationAddress, 0, 999)
          DDX_CONTROL_HANDLE(IDC_SCALE_IMAGE, m_ctlImage)
          END_DDX_MAP()

          };

          None of the base class DDX routines seem to get called, e.g. DDX_TEXT, DDX_INT_RANGE, etc. I set breakpoints in DDX_Text() and all others but only the DDX_CBString one gets hit. Could it have something to do with the way the macro's are defined? They are defined within a function body: (from atlddx.h)

          // DDX map macros
          #define BEGIN_DDX_MAP(thisClass) \
          BOOL DoDataExchange(BOOL bSaveAndValidate = FALSE, UINT nCtlID = (UINT)-1) \
          { \
          bSaveAndValidate; \
          nCtlID;

          #define DDX_TEXT(nID, var) \
          if(nCtlID == (UINT)-1 || nCtlID == nID) \
          { \
          if(!DDX_Text(nID, var, sizeof(var), bSaveAndValidate)) \
          return FALSE; \
          }
          // ....

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          Returning FALSE from a DDX method means that the data exchange method failed such that the rest of the data exchange process should be cancelled. You need to return TRUE from your DDX_CBString method unless (for example) validation of the item fails.

          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