wasim786nasir

Hello,

I am developing a program of multiple dailog box and, i have problem on how to pass variable from one dialog box to another.

and also i am trying to send the data over lan by TCP/IP but i do not where to put my code, as i am not able to use func send in my other dialog box's .cpp file. please help me how to proceed.

Wasim nasir



Re: Visual C++ General How to pass variable from one dialog box to other

Pintu Shukla



Assume you has Two Dialog A and B now you want to Pass data From A to B . a Simple way is create a object of B in your A now easily you can access all the member variable of B in A . Simply use your member variable of B in A Asign them value now inside B you can See that all those value is visible to you.Now Second question where to put TCP/IP code in your program it's Depend on you better you made a seperate File for all communication related work and according to your requirement in your project access the Function mention in your communication files.

Thanx





Re: Visual C++ General How to pass variable from one dialog box to other

Ramkrishna Pawar

Pintu Shukla wrote:


Assume you has Two Dialog A and B now you want to Pass data From A to B . a Simple way is create a object of B in your A now easily you can access all the member variable of B in A . Simply use your member variable of B in A Asign them value now inside B you can
Thanx

Not objects but pointer to other dialog class object, you will need to assign it other dialog's value before using it.

About the TCP/IP problem, can you post the code you have here




Re: Visual C++ General How to pass variable from one dialog box to other

Pintu Shukla



hello . wat's that. even you can assign it after Invoking the Dialog it's depend on your rquirement. you also can use user defined Fucntion and can invoke it from your dialog a and inside your user defined Function you can chage the 2nd Dialog member variable value with param parameters . which you are sending from 1st dialog by SendMessage() or PostMessage() . and there is no need to taking pointer to a object.everyone should familiar where to use pointer to a Object or simply a Object .Even in your above senario there is no need to use pointer to a Object.and if you want all the variable inside your OnInitDialog Function then only you have to assign them before using the dialog other wise you can assign them according to your requirement with the help of user Defined Message.

Thanx







Re: Visual C++ General How to pass variable from one dialog box to other

Sreedhar DVS

It can be done by SendMessage or PostMessage functions.

The other way is using 'extern' variable.






Re: Visual C++ General How to pass variable from one dialog box to other

GET@h

Hi,
I would suggest you to use an immutable class to hold the parameters you are passing from a Diablog box A to B.
You need to have pointer to B in A. And a method Accept(ParamsFromA* params) in your class B. Then you will need just to collect your parameters in class A and call instanceOfB->Accept(ParamsFromA* params).
For the question regarding TCP/IP. It's better to put the code in a Utilities package since it can be classified in a technical domain and should be independant of your application domain and workflow domain.
You can find more information about this by googling 'Layered architecture pattern'

Best regards,





Re: Visual C++ General How to pass variable from one dialog box to other

GET@h

Hi,

Just note that you socket has to be created in the main GUI thread (if it's an async communications)

I encountred this problem when trying to use CAsyncSocket for async communications.

Cheers,






Re: Visual C++ General How to pass variable from one dialog box to other

Sreedhar DVS

I think you want to share data between the classes; if so why can't you go for a friend function or else why can't you create an object of that class in the other and use that variables.

Your question is giving wrong sence "How to use tcp/ip in multiple dailog box program". Once revise your application design.

Cheers,