实际上存在的ID#为“错误:没有ID的数据交换控件”

时间:2018-10-06 22:07:20

标签: c++ windows mfc

运行应用程序并通过菜单调用某个对话框时,出现“调试断言失败!”的提示。弹出窗口和调试器中的以下错误消息:

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

导致它的行是:

DDX_Control(pDX, IDC_NEWPLAYERHEIGHTINCHES, m_newPlayerHeightInchesEdit);
实际上确实存在

ID 0x040E(十进制1038):resource.h中有一个#define IDC_NEWPLAYERHEIGHTINCHES 1038,resource.h包含在相关的源文件中(如果不存在,则会导致编译器错误),并将其分配给资源文件中的相应Edit控件。

所以我真的不知道发生了什么事。

编辑:这是对话框资源:

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

1 个答案:

答案 0 :(得分:0)

原来我是个白痴,完全忘记了在访问控件成员变量之前检查对话框是否已完成初始化。

建议任何通过Google或其他方式找到它的人:请确保您已完成!