Hi all, please help me for this problem.
I want exchange data between two MDI form(VC++/MFC), ex:
Note: F1 and F2 is extended from CFormView, not from Dialog
In Form1(name=F1) i have:
a CEdit(name=txtT1), a Button(name=cmdC1)
In Form2(name=F2) i have:
a CEdit(name=txtT2), a Button(name=cmdC2)
Now i want, when i show F1, input a text (ex: "abcd") into txtT1, and then click cmdC1. When click cmdC1, i will show F2 and transmit the text("abcd") to F2, on F2 form i have a function to receive this text and display this text on txtT2(this text can be changed).
When i click cmdC2, i want to transmit this text in txtT2 back to F1 and on F1 i have a function to receive this value and display on txtT1.
Please give me some code(in MFC)
Thanks very much.
(I can not find attach function, please get my project here: http://www.codeguru.com/forum/attachment.php attachmentid=14661)
I want exchange data between two MDI form(VC++/MFC), ex:
Note: F1 and F2 is extended from CFormView, not from Dialog
In Form1(name=F1) i have:
a CEdit(name=txtT1), a Button(name=cmdC1)
In Form2(name=F2) i have:
a CEdit(name=txtT2), a Button(name=cmdC2)
Now i want, when i show F1, input a text (ex: "abcd") into txtT1, and then click cmdC1. When click cmdC1, i will show F2 and transmit the text("abcd") to F2, on F2 form i have a function to receive this text and display this text on txtT2(this text can be changed).
When i click cmdC2, i want to transmit this text in txtT2 back to F1 and on F1 i have a function to receive this value and display on txtT1.
Please give me some code(in MFC)
Thanks very much.
(I can not find attach function, please get my project here: http://www.codeguru.com/forum/attachment.php attachmentid=14661)

MFC - exchange data between two CFormView form
salomon
Martin Roller
I use MDI, and all class extended from CFormView. I do not use Dialog.
I have written some code as your answer, but it does not work.
(please download my code project and give me a correct code:
this topic: http://www.codeguru.com/forum/showthread.php t=378367
or: http://www.codeguru.com/forum/attachment.php attachmentid=14661)
Thanks very much
Philippe Fier
Michael McD
There is no attach function here :-)
So t hese forms are part of the one project F2 is created by F1 Then you just need to add the variables you want to pass through to form2 to the Form2 constructor, so you can pass them in, and store them within F2, and set them to your text box text in the OnInitDialog method, probably.
If F2 is modeless, and you want to pass things back to F1, you probably need to use a function pointer to do that. If F2 is modal, you just expose the text as a string, and you need to store the text from the textbox back to the string you stored it in initially, in your close event handler. In MFC, once the window closes, you can't get the text from a textbox, as it no longer exists.