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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need help on how to set DDX control for dynamically created slider

Need help on how to set DDX control for dynamically created slider

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
6 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.
  • J Offline
    J Offline
    John502
    wrote on last edited by
    #1

    Hi, I have created slider bar dynamically using create function. now i want to create one integer control for the slider bar. Can any one help me how to create DDX control for the slider bar.. I have added DDX control in DoDataExchange function like this:- DDX_Slider(pDX,IDC_SLIDER1, m_Pos); but the app is crashing.. Can any one help me regarding this..? Any help will be appriciated.. Thanks Venki

    C 1 Reply Last reply
    0
    • J John502

      Hi, I have created slider bar dynamically using create function. now i want to create one integer control for the slider bar. Can any one help me how to create DDX control for the slider bar.. I have added DDX control in DoDataExchange function like this:- DDX_Slider(pDX,IDC_SLIDER1, m_Pos); but the app is crashing.. Can any one help me regarding this..? Any help will be appriciated.. Thanks Venki

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Does it crash or does it raise a debug assertion? If it is the later, check where the assert comes from, there are useful hints about problems as comments in the MFC code...

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      J 1 Reply Last reply
      0
      • C Code o mat

        Does it crash or does it raise a debug assertion? If it is the later, check where the assert comes from, there are useful hints about problems as comments in the MFC code...

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        J Offline
        J Offline
        John502
        wrote on last edited by
        #3

        Hi Code-o-mat, i am getting below error in the debugging state.. TRACE1("Error: no data exchange control with ID 0x%04X.\n", nIDC); along with this i am getting other error :- "An unsupported operation was attempted" can you please let me know what i can do now..? Thanks Venki

        C 1 Reply Last reply
        0
        • J John502

          Hi Code-o-mat, i am getting below error in the debugging state.. TRACE1("Error: no data exchange control with ID 0x%04X.\n", nIDC); along with this i am getting other error :- "An unsupported operation was attempted" can you please let me know what i can do now..? Thanks Venki

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Well, what this generally means is that it did not find any control with that id (IDC_SLIDER1) on the dialog. Are you sure that is the ID you gave to your dynamically created slider? And are you sure you placed the DDX_Slider entry in the class of the correct dialog? Also, are you sure you created your slider BEFORE DoDataExchange runs? If you did something like this:

          BOOL CMyDialog::OnInitDialog()
          {
          __super::OnInitDialog();
          m_mySlider.Create(...)
          ...

          That won't work since during the __super::OnInitDialog() call your DoDataExchange will be fired...so instead, do it like:

          BOOL CMyDialog::OnInitDialog()
          {
          m_mySlider.Create(...)
          __super::OnInitDialog();
          ...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          J 1 Reply Last reply
          0
          • C Code o mat

            Well, what this generally means is that it did not find any control with that id (IDC_SLIDER1) on the dialog. Are you sure that is the ID you gave to your dynamically created slider? And are you sure you placed the DDX_Slider entry in the class of the correct dialog? Also, are you sure you created your slider BEFORE DoDataExchange runs? If you did something like this:

            BOOL CMyDialog::OnInitDialog()
            {
            __super::OnInitDialog();
            m_mySlider.Create(...)
            ...

            That won't work since during the __super::OnInitDialog() call your DoDataExchange will be fired...so instead, do it like:

            BOOL CMyDialog::OnInitDialog()
            {
            m_mySlider.Create(...)
            __super::OnInitDialog();
            ...

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            J Offline
            J Offline
            John502
            wrote on last edited by
            #5

            Hi Code-o-mat, I am able to solve the problem with the help of your tip, thank you so much for your help. I have one more small doubt, i have created pointer object for the CSliderCtrl like this: CSliderCtrl *track_bar; trakbar = new CSliderCtrl; Can't we create normal object instead of pointer object..? if there is any way to create that please kindly let me know.. Thanks Venki

            C 1 Reply Last reply
            0
            • J John502

              Hi Code-o-mat, I am able to solve the problem with the help of your tip, thank you so much for your help. I have one more small doubt, i have created pointer object for the CSliderCtrl like this: CSliderCtrl *track_bar; trakbar = new CSliderCtrl; Can't we create normal object instead of pointer object..? if there is any way to create that please kindly let me know.. Thanks Venki

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              Why don't you simply create a member of your dialog class of type CSliderCtrl? Like this:

              class CMyDialog: public CDialog
              {
              ...
              CSliderCtrl m_myPreciousSlider;
              ...
              };

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

              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