Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Posted
Comments
[no name] 18-Oct-12 9:19am    
Create an event
Argonia 18-Oct-12 10:21am    
You can try sending a message

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.
 
Share this answer
 
Comments
fjdiewornncalwe 18-Oct-12 10:39am    
+5. That's how I've done it.
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900