SDI(单文档界面)MFC VC ++ 2015 [英] SDI(single document interface) MFC VC++ 2015

查看:235
本文介绍了SDI(单文档界面)MFC VC ++ 2015的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SDI中添加了两个对话框。

对话1:位置

对话2:速度

现在我想添加一个变量或函数。如何或在何处添加可在两个对话框中访问的变量或函数。该怎么办???



我尝试过:



我在SDI中添加了两个对话框。现在我想要一个if文件。

对话1:位置

对话2:速度

如何添加在两个对话框中都可访问的变量或函数。怎么做???

I have added two dialogs in SDI.
Dialog 1: Position
Dialog 2: Velocity
Now i want to add a variable or function. How or where to add a variable or function which is accessible in both dialogs. what to do???

What I have tried:

I have added two dialogs in SDI. Now i want to a if file.
Dialog 1: Position
Dialog 2: Velocity
How to add a variable or function which is accessible in both dialogs. what to do???

推荐答案

你需要一些常见的数据,可能是永久类对象(如应用程序或文档)中的成员或全局对象。您可以通过一些PostMessage体系结构实现并将数据作为参数发送,或者通过指向两个对话框的指针访问全局模型对象。
You need some common data, possible is it as member in a permanent class object (like the app or document) or as global object. You can this achieve via some PostMessage architecture and send the data as parameters, or as global model object which is accessable via pointers to both dialogs.


假设对话框共享相同的父窗口,任何<这两个父窗口的code> public 方法都可以访问。

Eg假设父窗口(比如 MainWindow )实现了一个公共方法(比如 getMass()),那么,在任何一个你可以写的对话框:

Assuming the dialogs share same parent window, any public method of such parent window is accessible to both.
E.g. suppose the parent window (say MainWindow) implements a public method (say getMass()), then, in any of dialogs you may write:
MainWindow *pmw = reinterpret_cast<MainWindow *> (GetParent());
int mass = pmw->getMass();


这篇关于SDI(单文档界面)MFC VC ++ 2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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