[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


DDX_Control - valid arguments?

Posted on 2004-10-26
Medium Priority
Last Modified: 2013-11-20
I have a fairly complicated dialog that I need to map/unmap sets of controls.  I didn't want to have 30+ control variables running around, so I thought I would organize things in a structure.  So, in my DataExchange method, after the AFX wrappers, I have:

         DDX_Control(pDX, IDC_A_11_STATIC, m_BankA.cGunType[0].cLabels[0]);
         DDX_Control(pDX, IDC_A_12_STATIC, m_BankA.cGunType[0].cLabels[1]);
         DDX_Control(pDX, IDC_A_13_STATIC, m_BankA.cGunType[0].cLabels[2]);

the above is a code snippet - compiles fine.  The .cLabels[n] reference a custom activeX control.  Looking at this code, I would think that I have something equivalent to :

         DDX_Control(pDX, IDC_A_11_STATIC, m_cLabels[0]);  // example

However, using the structure notion results in an assertion violation, while the array reference does not.

Today's question is - why?  Both code snippets decompose to the same discrete variable location, or so I think...
What am I missing?
Question by:charles_gilley
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 45

Expert Comment

ID: 12419015
What is missing? - support from the IDE for this second method.  What the DDX tries to do is assign ONE variable to ONE control.  You get the assert as the variable doesn't make sense for the assignment.

What you can do for the DDX routine (IF the control ID's are incremented by one) is have it in a loop

for(int i = 0; i < 3; i++)
  DDX_Control(pDX, IDC_A_11_STATIC+i, m_BankA.cGunType[0].cLabels[i]);

Author Comment

ID: 12420670

  How is your method different from mine other than you are using a loop, and I unrolled mine?
I'm coding this by hand, so I don't care about the IDE at all.  I'm just wondering about the structure
reference of the control.....

Sorry to be dense...
LVL 45

Expert Comment

ID: 12421471
I may not of understood you.
I thought you were attempting a shortcut where you expected the DDX to 'know' how large the array was and automatically assign variables to the controls until the end of the array was reached.

What ASSERT do you get?
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 12422788
Nope - been there, done that, have the t-shirt :).  That's a newbie mfc question, and I'm just about 12" above newbie status... ;)

Here's the real code snippet:

      DDX_Control(pDX, IDC_PS_TYPE_STATIC, m_cPowerSupplyStatic);
      DDX_Control(pDX, IDC_TITLE_STATIC, m_cTitleStatic);

         //DDX_Control(pDX, IDC_BANK_A_GBOX, m_BankA.cGroupBox);

         // Gun 1:

         DDX_Control(pDX, IDC_A1_DEVICE_BTN, m_BankA.cGunType[0].cDeviceTypeBtn);

A couple of notes.  First, the AFX_DATA_MAP is the typical area added by the IDE.  Note the standard single control variable passed into DDX_Control.  Works fine.

Now, after the last comment - this DDX_Control statement is added manually and is misbehaving.  The cDeviceTypeBtn is defined as a control, it all compiles, but when it executes I get an access violation (C0000005) inside of SubclassWindow.  I'm going to do more testing...
LVL 45

Accepted Solution

AndyAinscow earned 450 total points
ID: 12423198
Is m_BankA.cGunType[0].cDeviceTypeBtn valid?
Step into the DDX_Control function and find the line asserting.

Author Comment

ID: 12423427
I believe so.  I step into the DDX_Exchange code... we make it all the way into the SubclassWindow call and crater at PreSubclassWindow();  Just walked through the execution for a standard single control - looks the same as the other.  

fwiw, I've duplicated this behavior with my controls (custom activeX) and standard CButton controls, so I don't think I have anything weird in this area.

Wait a minute... the address displayed by the debugger in EVC++ says 0x000000 for the function.  Hmmmm...

Author Comment

ID: 12423458
Okay, I've got a class problem / inheritance issue.  When I create a structure and possibly an array, I've got a null pointer around for this virtual function.

Author Comment

ID: 12816341
Whoops, forgot about this one.  Apologies to one and all... Andy, thanks for your help and suggestions. points to you...

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question