Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been playing with different controls trying to learn how they operate. Any comments and/or suggestions will be greatly appreciated. Thanks

If I create a combobox like:

MIDL
CComboBox *CaliberBox = new CComboBox;
       CaliberBox->Create(WS_CHILD | WS_VISIBLE |
       WS_VSCROLL | CBS_DROPDOWNLIST | CBS_SORT,
       CRect(20, 85, 130, 30), this, 0x1448);

       CaliberBox->AddString(L".223 Rem");
       CaliberBox->AddString(L".308 Win");
       CaliberBox->AddString(L".45/70 Gov't");


How do I link a 'control' variable and a 'value' variable?

I know I need to add the following to the DoDataExchange, but what do I need to add as the IDC ?

DDX_Control(pDX, ??????, m_wndCaliber);
DDX_CBString(pDX, ??????, m_sCaliber);

and when using the 'new' operator, I don't think I need to 'delete' the CaliberBox if it's created in a dialog window. Am I correct?

PS (What exactly, is '0x1448' in the create initializer?) I got this from some example I found somewhere online.

Thanks again
-DrB
Posted

i believe you should read this link[^]

in your creation you would have to assign an control id. in your case you have used 0x1448,

Better define a macro something like this
#define IDC_CALIBERBOX 0x1448


then in Create use IDC_CALIBERBOX instead the actual number(reason to do this to avoid some issue of change. say if you need to change only place you will have to change is in the macro definition)

and in your

MIDL
DDX_Control(pDX,IDC_CALIBERBOX, m_wndCaliber);
DDX_CBString(pDX,IDC_CALIBERBOX, m_sCaliber);
 
Share this answer
 
Comments
DrBones69 12-Jul-11 22:39pm    
This is good info, but I receive an assertion failure in dlgdata.cpp at line 40. This has something to do with DDX. Not quite sure what to do next.
I never used DDX_Control before but i guess, it has something to do with it if this error occurs after adding those.

Make sure they are not causing
CaliberBox->AddString(L".223 Rem");
     CaliberBox->AddString(L".308 Win");
     CaliberBox->AddString(L".45/70 Gov't");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900