与儿童课堂的交流 [英] communication to a child class

查看:41
本文介绍了与儿童课堂的交流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的应用程序中,单击按钮后会打开一个对话框.

Hello all,

In my app I open a dialog when a button is clicked.

CGet_DataDlg* obj_Get = new CGet_DataDlg;
obj_Get->setParent(this);

obj_Get->Create(IDD_GET_DATA,this);
CRect rect;
this->GetWindowRect(rect);
        obj_Get->SetWindowPos(&CWnd::wndTop,rect.left+17,rect.top+56,907,127,SWP_SHOWWINDOW);
obj_Get->ShowWindow(SW_SHOW);



新对话框仍然允许用户单击主对话框中的其他按钮.

用户根据按钮在主对话框中单击
但是如何告诉孩子主体上有一个按钮被按下?

谢谢大家!



The new dialog will still allow the user to click other buttons in the main dialog.

According to the buttons the user clicks in the main dialog
But how can I tell the child that there is a button pressed in the main?

Thanks to all!

推荐答案

您可以在父窗口中保留子窗口的HWND.取消对父窗口的按钮的控制后,当您按住子窗口的HWND时,可以向子窗口发送一条消息,如下所示:

:: SendMessage(hwndChild,WM_URSE_MESSAGE,NULL,NULL).

然后,您可以在子窗口中接收该消息,并按您的想法处理该消息.
You can hold the HWND of the child windows in the parent windows. When you detech the button of parent windows was clicked, you can send a message to the child windows as you hold the HWND of the child, some code like the following:

::SendMessage(hwndChild, WM_URSE_MESSAGE, NULL, NULL).

Then you can receive the message in your child windows and process the message as you thinking.


您可以执行此操作,但实际上不必这样做.如果有任何业务逻辑(取决于主窗口中的某些按钮),则直接调用该逻辑.拆分消息业务逻辑,外观和消息处理逻辑(模型/视图/控制器).让消息发生,不要复制它们.
You can do that, but you really don''t have to. If there is any business logic, dependent on some button in the main window, just call directly that logic. Split the message business logic, look and message handling logic (Model/View/Controller). Let the messages to happen, and don''t multiplicate them.


这篇关于与儿童课堂的交流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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