动态组合框和变量(特别是控制和值) [英] Dynamic ComboBoxes and Variables (specifically Control & Value)

查看:78
本文介绍了动态组合框和变量(特别是控制和值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试各种控件,以了解它们的操作方式.任何意见和/或建议将不胜感激.谢谢

如果我创建一个组合框,如:

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:

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");



如何链接控件"变量和值"变量?

我知道我需要将以下内容添加到DoDataExchange中,但是我需要添加什么作为IDC?

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

当使用"new"运算符时,如果在对话框窗口中创建了CaliberBox,我认为不需要删除" CaliberBox.我说得对吗?

PS(确切地说,创建初始化器中的"0x1448"是什么?)我是从网上某个地方找到的一些例子得到的.

再次感谢
-DrB



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

推荐答案

我相信您应该阅读此
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



然后在创建"中使用IDC_CALIBERBOX而不是实际数字(这样做的原因是为了避免某些更改问题.例如,如果您只需要更改位置,则必须在宏定义中进行更改)

并在您的



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

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


我以前从未使用过DDX_Control,但是我想,如果在添加这些错误之后发生此错误,则与之相关.

确保它们不会引起
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");


这篇关于动态组合框和变量(特别是控制和值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆