views:

129

answers:

2

hello friends, I am working on a small MFC application..since am new to MFC I am not familiar with all the user controls and classes...anyways my question is "how to communicate between 2 dialog windows"..Normally in C# there will be a panel so we can hide and hold the data's in the forms respectively,but I am not sure,how we can do that in Mfc.Actually I did do that using PropertySheet by attaching property pages,in that I had some restriction...So I am keen to know if there are any other way that I can achieve this.If anybody know about this,please help me....

A: 

One of the easiest ways is to pass a reference between the forms that need to communicate. For example, you could have a "master" form that creates two "child" forms and passes a variable to each form (on instantiation) that references the other form.

Michael Todd
hey mike,thanks for ur reply,can you show me an example or can u refer me some nice article related to that...I would really appreciate your help
kiddo
+2  A: 

Are you building a Dialog or SDI/MDI type app?

If the dialog windows are from two different processes then you can use registered messages for interprocess communication: http://msdn.microsoft.com/en-us/library/ms644947%28VS.85%29.aspx.

If the dialog windows are from an SDI or MDI application, then there will be a class derived from CWinApp or CWinAppEx in the code that Visual Studio generates for you: http://msdn.microsoft.com/en-us/library/362kaah4%28VS.80%29.aspx. There will also be a class derived from CFrameWnd or CFrameWndEx (most likely called CMainFrame): http://msdn.microsoft.com/en-us/library/za93adby%28VS.80%29.aspx.

You can use either of those (depending on what type of communication you are talking about it may make sense to use one or the other or both) much like you would a C# panel.

If the dialog windows are both from a Dialog app then you can use the CDialog derived class in the application like you would a C# panel.

If the dialogs just need to call a method in one another to update data or something like that (and are from the same application), you can just pass them pointers to each other.

adam
i passed as pointers but it isnt working..if u want i can post the code....
kiddo
Yeah, post the code. Also, when you say it isn't working do you mean it compiles, but the calls don't happen; or do you mean it doesn't compile?
adam