Reputation: 51
There are several ways to use SendMessage()
::SendMessage(h, MY_MSG ,0,0);
MFC modal
Let's ptr having child Dialog box Handle then we can use this modal
ptr->SendMessage(MY_MSG,0,0);
But How can I get child dialog Box handle once I clicked a button in parent Dialog box see this.. I write the code
void CCustomMessageDlg::OnBnClickedOpen(){
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.DoModal();
}
I Need Send Custom Message to child Dialog using SendMessage() API once Button is clicked. Can You Please Suggest A solution for this problem
Upvotes: 0
Views: 1363
Reputation: 11406
You cannot send a message to the dialog after DoModal()
returns, because the dialog will already be destroyed.
In case you want to pass data to the dialog, you can add a member variable to your child dialog, say:
CString m_strMyData;
Then use:
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.m_strMyData = "Test";
d2.DoModal();
and access m_strMyData
from within the child dialog.
Upvotes: 1