简体   繁体   English

向MFC对话框控件添加变量

[英]Add variable to mfc dialog control

This is a very simple problem, but I could not find a solution to it. 这是一个非常简单的问题,但是我找不到解决方案。 I have a dialog A, which when clicked a button opens another dialog B with a single edit box. 我有一个对话框A,单击该按钮可以打开一个带有单个编辑框的对话框B。 I want to add an integer variable to it. 我想给它添加一个整数变量。
The usual way of adding variables which is right clicking the edit box and "add variable" is greyed out. 右键单击编辑框和“添加变量”的添加变量的常用方式显示为灰色。 I presume that it's because I haven't declared a separate class for the dialog, since the variable is used only in Dialog A code I don't want to add a separate class for Dialog B. 我认为这是因为我没有为对话框声明单独的类,因为该变量仅在Dialog A代码中使用,所以我不想为Dialog B添加单独的类。
What should I do? 我该怎么办?

Thanks. 谢谢。

If you want to customise the behaviour of dialog B in any way (including adding variables for controls), you must declare a class for it. 如果要以任何方式自定义对话框B的行为(包括为控件添加变量),则必须为其声明一个类。

You say that the variable is only used in dialog A code, but that doesn't mean that dialog A is the owner of that variable. 您说该变量仅在对话框A的代码中使用,但这并不意味着对话框A是该变量的所有者 Dialog B owns it, so dialog B needs a class. 对话框B拥有它,因此对话框B需要一个类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM