从一个对话框获取变量值到另一个对话框 [英] Getting a variable value from one dialog to another

查看:106
本文介绍了从一个对话框获取变量值到另一个对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个对话框是模式对话框,但第二个不是.因此,当我调用它时,第一个不会关闭.我认为虽然第一个是活动的",但第二个可能能够接收变量值.是吗?

My first dialog is modal, but the second one is not. So when i call it, the first doesn''t close. I think while the first is "alive", the second might be able to receive the variable value. Right?

推荐答案

要么将自定义的Windows消息发送到第二个窗口,然后在第二个窗口中使用消息处理程序,要么让第一个调用公共方法第二个对象的CDialog派生对象.

但是,如果我从您的上一个问题中正确回忆起,您将以第二个对话框作为模态对话框的形式从第一个对话框开始. 这意味着第一个对话框将在第二个对话框运行时有效地被挂起.当第二个打开时,它将永远不会获得任何击键.在对您正在做的事情的误解中,您正在编码一种情况,您的设计特别禁止这种情况发生.


Either send a custom windows message to the hWnd of the second and have a message handler for it in the second, or have the first call a public method of the CDialog derived object of the second.

However, if I recall correctly from a previous question of yours, you are starting the second dialog as a modal dialog from the first. That means that the first dialog will effectively be suspended while the second is running. It will never get any keystrokes while the second is open. In my (mis)understanding of what you are doing, you are coding for a situation that your design specifically precludes from ever occurring.


ge6a93后来写道:
ge6a93 later wrote:

我的第一个对话框是模式对话框,而第二个对话框不是模式对话框.

My first dialog is modal, but the second one is not.



好的. :)

如果偶然地,这是您在创建第二个对话框时要用来初始化第二个对话框的值,则编写第二个对话框的类的构造函数以将其接受为参数.


如果您的第一个对话框创建了第二个对话框,则它具有(或至少具有)访问与第二个对话框关联的CDialog派生对象实例的权限.然后,只要第二个对话框仍然存在,您就可以使用第一段中的任何建议将值发送到第二个对话框.



Good. :)

If, by chance, this is a value that you want to use to initialize your second dialog when you create it, then write the constructor of your second dialog''s class to accept it as a parameter.


If your first dialog created the second, it has (or at least had) access to the CDialog derived object instance associated with the second dialog. Then, as long as second dialog still exists, you could use either of the suggestions in my first paragraph to send the value to the second dialog.


您可以在以下位置设置和获取数据变量CDialog对象的DoDataExchange()函数.
You can set and get your data variables in the DoDataExchange() function of your CDialog objects.


您可以保存,修改和请求交换数据"
在应用程序对象上也是如此:)
You could hold, modify and request your "exchange data"
at the application object too :)


这篇关于从一个对话框获取变量值到另一个对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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