Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello dear,
Actually i'm having two dialogs in my application along with a Text Field in both.And i want any thing i wrote in 2nd dialog's textbox ,it should display in 1st dialog's text box through a button click in 2nd Dialogbox.
I'm sure,it can possible using either "SendMessage()" OR "PostMessage()" .

But now i'm failing , how to get the handle of 1st Dialog's Textbox which we need to pass in SendMessage() as parameter in 2nd Dialog's sourcecode.

Kindly Please help me soon.Thanks
Posted
Updated 17-Sep-11 9:26am
v8

You can simply do it through the CWinApp that runs the show... He has the pointers to everyone, so you can just pass the handle to either dialog as part of the initialization.

Somewhere in CWinApp():
CDialog1 dialog1;
CDialog2 dialog2;

dialog1.mp_other_dialog = &dialog2;
dialog2.mp_other_dialog = &dialog1;

where:
CDialog1 and CDialog2 are derived from CDialog.
and:
CDialog* mp_other_dialog;

Alternatively, you can also make a method in whatever parent class (again, CWinApp could be used) that will return a requested pointer. For example:
CWinApp *theApp;
CDialog* dialog = theApp->GetDialog(TYPE);
 
Share this answer
 
Comments
litupkj 16-Sep-11 16:01pm    
Thanks Albert.

Can you please give more clear steps,so that we can impliment your above suggestion in SendMessage() / PostMessage() methods.
Albert Holguin 17-Sep-11 20:52pm    
I don't know how much more clear it can be without writing your code for you. Ask a specific question.
You can use "SendMessage()" in the 1st dialog an d "OnReceiveMessage" in the 2nd dialog..
 
Share this answer
 
Comments
litupkj 16-Sep-11 16:07pm    
Thanks Painjoshem.
But Can you please tell me how to get the handle of a TextBox of one Dialog in another Dilog's soucecode.
epanjohura 19-Sep-11 5:04am    
can you tell me exactly what you want to put in the 1st / 2nd dialogs?

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