Click here to Skip to main content
15,911,139 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I use a push button check box to initiate a modeless dialog. On exiting I want to to notify the parent dialog so that I can uncheck the check box, among other things.

I've used SendMessage to communicate with edit controls within the same dialog, but not having any success between dialogs. The online help I get is confusing.
I can't get a clear explanation of how to connect the pipes.

What I really need is a guide for idiots to get me started, or at the least a simple explanation.

Thanks for any and all help.

Well, now I'm off in the weeds...message sent but not going where I expect.

To clarify, parent has two child dialogs...neither child needs to communicate with the other, but both need to notify the parent when they exit. The child isn't instantiated until push button is clicked, so I have no handle on init of my main.

And these are pop-up, not child, dialogs...if that makes a difference.
Posted
Updated 3-Jun-11 10:12am
v4

1 solution

SendMessage() is part of CWnd (although there is also one that is directly part of WinAPI), meaning any CWnd derived class contains this call... if you need to message between two CDialogs, which are CWnd derived, you just need to give them each others handles, either as CWnd or as CDialog, then you can just message between them directly.

say you have...
CDialog MainDialog;


that owns...
CDialog ChildDialog1;
CDialog ChildDialog2;


within either the constructor or InitDialog() of MainDialog...
ChildDialog1.m_hDialog = &ChildDialog2; //where you've defined m_hDialog to be either
ChildDialog2.m_hDialog = &ChildDialog1; //  CWnd* or CDialog* (either will work)


now for them to message each other directly,
m_hDialog->SendMessage(...); //within either ChildDialog


[edit]
You're missing the point... if you have a handle to any CWnd, you can message to it.

//Within main dialog
CMainDialog::OnButtonClick()
{
  COtherDialog Child;
  Child.m_hParent = this;

  Child.DoModal();
}

//Within COtherDialog
COtherDialog::OnButtonClickity()
{
  m_hParent->SendMessage(...);
  ...yada, yada, yada...
 return;
}

[/edit]
 
Share this answer
 
v3
Comments
sbwilliams59 3-Jun-11 15:42pm    
Thanks Albert...again I've improved my question if you wouldn't mind looking again.
Albert Holguin 3-Jun-11 17:52pm    
updated my answer
sbwilliams59 6-Jun-11 12:45pm    
got the point, missing the handle..."this" is the handle???
didn't realize that...thanks for the Windows 101 lesson.

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