0

When I run my application and call a certain dialog box via a menu, I get a "Debug assertion failed!" popup and the following error message in the debugger:

"f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgdata.cpp(39) : AppMsg - Error: no data exchange control with ID 0x040E.

The line that's causing it is:

DDX_Control(pDX, IDC_NEWPLAYERHEIGHTINCHES, m_newPlayerHeightInchesEdit);

ID 0x040E (decimal 1038) does in fact exist: there's a #define IDC_NEWPLAYERHEIGHTINCHES 1038 in resource.h, resource.h is included in the relevant source file (it'd cause a compiler error if it weren't), and it's assigned to the appropriate Edit control in the resource file.

So I really have no clue what's going on.

EDIT: This is the dialog box resource:

IDD_NEWPLAYER DIALOGEX 0, 0, 285, 268
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "OK",IDOK,180,247,50,14
    PUSHBUTTON      "Cancel",IDCANCEL,230,247,50,14
    LTEXT           "Given Name:",IDC_STATIC,13,15,42,8
    EDITTEXT        IDC_GIVENNAME,55,15,80,12,ES_AUTOHSCROLL
    LTEXT           "Family name:",IDC_STATIC,154,15,43,8
    EDITTEXT        IDC_EDIT2,197,15,80,12,ES_AUTOHSCROLL
    LTEXT           "Height:",IDC_STATIC,9,30,24,8
    EDITTEXT        IDC_NEWPLAYERHEIGHTFEET,33,30,10,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPLAYERHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,43,30,11,14
    LTEXT           "'",IDC_STATIC,55,30,8,8
    EDITTEXT        IDC_NEWPLAYERHEIGHTINCHES,62,30,25,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINHEIGHTINCHES,"msctls_updown32",UDS_ARROWKEYS,87,30,11,14
    LTEXT           """",IDC_STATIC,99,30,8,8
    LTEXT           "Weight (lbs.):",IDC_STATIC,111,30,45,8
    LTEXT           "Max. Fitness:",IDC_STATIC,23,45,44,8
    EDITTEXT        IDC_NEWPLAYERMAXFITNESS,67,45,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINMAXFITNESS,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,45,11,14
    LTEXT           "Max. Energy:",IDC_STATIC,112,45,44,8
    EDITTEXT        IDC_NEWPLAYERMAXENERGY,156,45,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINMAXENERGY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,45,11,14
    LTEXT           "Age:",IDC_STATIC,230,45,16,8
    EDITTEXT        IDC_NEWPLAYERAGE,246,45,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINAGE,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,45,11,14
    LTEXT           "Pass blocking:",IDC_STATIC,21,60,46,8
    EDITTEXT        IDC_NEWPLAYERPASSBLOCKING,67,60,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPASSBLOCKING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,60,11,14
    LTEXT           "Run blocking:",IDC_STATIC,112,60,44,8
    EDITTEXT        IDC_NEWPLAYERRUNBLOCKING,156,60,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINRUNBLOCKING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,60,11,14
    LTEXT           "Speed:",IDC_STATIC,222,60,24,8
    EDITTEXT        IDC_NEWPLAYERSPEED,246,60,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINSPEED,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,60,11,14
    LTEXT           "Strength:",IDC_STATIC,35,75,32,8
    EDITTEXT        IDC_NEWPLAYERSTRENGTH,67,75,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINSTRENGTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,75,11,14
    LTEXT           "Acceleration:",IDC_STATIC,113,75,43,8
    EDITTEXT        IDC_NEWPLAYERACCELERATION,156,75,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINACCELERATION,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,75,11,14
    LTEXT           "Pass defense:",IDC_STATIC,200,75,46,8
    EDITTEXT        IDC_NEWPLAYERPASSDEFENSE,246,75,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPASSDEFENSE,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,75,11,14
    LTEXT           "Pass rush:",IDC_STATIC,33,90,34,8
    EDITTEXT        IDC_NEWPLAYERPASSRUSH,67,90,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPASSRUSH,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,90,11,14
    LTEXT           "Run defense:",IDC_STATIC,112,90,44,8
    EDITTEXT        IDC_NEWPLAYERRUNDEFENSE,156,90,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINRUNDEFENSE,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,90,11,14
    LTEXT           "Agility:",IDC_STATIC,223,90,23,8
    EDITTEXT        IDC_NEWPLAYERAGILITY,246,90,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINAGILITY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,90,11,14
    LTEXT           "Receiving:",IDC_STATIC,33,105,34,8
    EDITTEXT        IDC_NEWPLAYERRECEIVING,67,105,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINRECEIVING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,105,11,14
    LTEXT           "Ball handling:",IDC_STATIC,113,105,43,8
    EDITTEXT        IDC_NEWPLAYERBALLHANDLING,156,105,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINBALLHANDLING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,105,11,14
    LTEXT           "Jumping:",IDC_STATIC,216,105,30,8
    EDITTEXT        IDC_NEWPLAYERJUMPING,246,105,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINJUMPING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,105,11,14
    LTEXT           "Route running:",IDC_STATIC,18,120,49,8
    EDITTEXT        IDC_NEWPLAYERROUTERUNNING,67,120,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINROUTERUNNING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,120,11,14
    LTEXT           "Tackling:",IDC_STATIC,127,120,29,8
    EDITTEXT        IDC_NEWPLAYERTACKLING,156,120,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINTACKLING,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,120,11,14
    LTEXT           "PK accuracy:",IDC_STATIC,204,120,42,8
    EDITTEXT        IDC_NEWPLAYERPLACEKICKACCURACY,246,120,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPLACEKICKACCURACY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,120,11,14
    LTEXT           "PK power:",IDC_STATIC,33,135,34,8
    EDITTEXT        IDC_NEWPLAYERPLACEKICKPOWER,67,135,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPLACEKICKPOWER,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,87,135,11,14
    LTEXT           "Punt accuracy:",IDC_STATIC,107,135,49,8
    EDITTEXT        IDC_NEWPLAYERPUNTACCURACY,156,135,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPUNTACCURACY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,135,11,14
    LTEXT           "Punt power:",IDC_STATIC,206,135,40,8
    EDITTEXT        IDC_NEWPLAYERPUNTPOWER,246,135,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPUNTPOWER,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,135,11,14
    EDITTEXT        IDC_NEWPLAYERWEIGHT,156,30,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINWEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,176,30,11,14
    LTEXT           "Injury-proneness:",IDC_STATIC,187,30,59,8
    EDITTEXT        IDC_NEWPLAYERINJURY,246,30,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPININJURY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,30,11,14
    LTEXT           "Passing accuracy:",IDC_STATIC,54,150,58,8
    EDITTEXT        IDC_NEWPLAYERPASSINGACCURACY,112,150,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPASSINGACCURACY,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,132,150,11,14
    LTEXT           "Passing power:",IDC_STATIC,196,150,50,8
    EDITTEXT        IDC_NEWPLAYERPASSINGPOWER,246,150,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINPASSINGPOWER,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,150,11,14
    LTEXT           "Offensive awareness:",IDC_STATIC,40,165,72,8
    EDITTEXT        IDC_NEWPLAYEROFFENSIVEAWARENESS,112,165,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINOFFENSIVEAWARENESS,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,132,165,11,14
    LTEXT           "Defensive awareness:",IDC_STATIC,174,165,72,8
    EDITTEXT        IDC_NEWPLAYERDEFENSIVEAWARENESS,246,165,20,12,ES_AUTOHSCROLL | ES_READONLY | ES_NUMBER
    CONTROL         "",IDC_SPINDEFENSIVEAWARENESS,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,266,165,11,14
    LTEXT           "Best position:",IDC_STATIC,58,195,44,8
    EDITTEXT        IDC_NEWPLAYERBESTPOSITION,102,195,80,12,ES_AUTOHSCROLL | ES_READONLY
END
Kurt Weber
  • 176
  • 10
  • There are several possible causes listed in answers to [this question](https://stackoverflow.com/questions/13292166/cdialogcreate-fails-for-dialog-with-activex-control) – 1201ProgramAlarm Oct 07 '18 at 00:23
  • One of them relates to .NET, two of them are ActiveX-specific, and the other two are something I've already ruled out as I explained in my post. – Kurt Weber Oct 07 '18 at 01:15
  • 2
    "*there's a #define IDC_NEWPLAYERHEIGHTINCHES 1038 in resource.h, resource.h is included in the relevant source file (it'd cause a compiler error if it weren't), and it's assigned to the appropriate Edit control in the resource file.*" Are you also `#include`'ing `resource.h` in your resource file? If not, it will still compile, but the resource will be named literally `"IDC_NEWPLAYERHEIGHTINCHES"` and not `1038`. You can use a resource viewer/editor to verify that. – Remy Lebeau Oct 07 '18 at 05:12
  • Yes, it is included. – Kurt Weber Oct 07 '18 at 16:42
  • 2
    It may sound elementary, but did you check if a control with this ID (not the ID itself) actually exists in the dialog resource? Maybe it was accidentally changed or deleted. Otherwise, check the declarations in the dialog class, the initialization, assignments etc etc, esp compare everything regarding this control (declaration, initialization etc) to another control that doesn't have this problem; there must be something wrong. – Constantine Georgiou Oct 08 '18 at 09:13
  • Show us the actual dialog makeup from the RC file. You can open it in text editor and page the design of the dialog. You will see if the ID is used or not. – Andrew Truckle Oct 08 '18 at 11:36
  • @AndrewTruckle Edited the question to add it; you'll see it on line 16. – Kurt Weber Oct 13 '18 at 16:55
  • Never mind, I figured out what it was (and explained in the answer below). – Kurt Weber Oct 13 '18 at 18:16

1 Answers1

-1

Turns out I'm an idiot and completely forgot to check that the dialog box had finished initializing before accessing control member variables.

Advice to anyone who finds this via Google or whatever: make sure you've done that!

Kurt Weber
  • 176
  • 10
  • 1
    Why not show your actual resolution in the answer rather than just state what you did? This will be more useful to have a complete answer and benefit others. – Andrew Truckle Oct 13 '18 at 20:05
  • 1
    I did: check for the dialog box to finish initialization before trying to access control member variables. That's the resolution: make sure your code does that. – Kurt Weber Oct 13 '18 at 20:08
  • 7
    That is what is am saying! Show your code doing that. Visually show the concept you are explaining. – Andrew Truckle Oct 14 '18 at 04:55
  • 1
    Echoing @AndrewTruckle above, that it would help to provide a code example to others on what it means to 'finish initialization'. – David Carr Nov 18 '20 at 03:18