简体   繁体   English

mfc子对话框如何知道父对话框是否按“取消”按钮?

[英]mfc How can Child dialog know if Parent dialog push “cancel” button?

I made Child dialog in Parent dialog's tab control like this. 我在“父”对话框的选项卡控件中创建了“子”对话框。 dialog 对话

Child dialog uses database, so it has to be "db.Close()" when I push Parent dialog's "cancel" button. 子对话框使用数据库,因此当我按下父对话框的“取消”按钮时,它必须是“ db.Close()”。

In this case, How can Child dialog know if Parent dialog push "cancel" button? 在这种情况下,子对话框如何知道父对话框是否按下“取消”按钮?

OR... 要么...

How can Child dialog know right before destroyed by Parent dialog? 子对话框在被父对话框破坏之前如何知道?

1) You could make a message handler in child's class and send it a message from it's parrent. 1)您可以在孩子的班级中创建一个消息处理程序,然后从其父级发送一条消息。

2) Other way is to make a public method in child's class who clears the window when DB is closed. 2)另一种方法是在子类中创建一个公共方法,该方法在关闭DB时清除窗口。 From the parent call this method on child's object. 在父对象上,对子对象调用此方法。

The first is much better and much safer solution. 第一个是更好,更安全的解决方案。

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

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