wasim786nasir

Hello,

I am trying to build a dialog based program to communicate via lan. i am using MFC files ( .exe as statistical link libraries )

i don't know where to put the code of initialization, as my in myprogram i have kept it in app.cpp file but i am not able use the send - recv function from other dialog boxes. I tried to implement it by as global variable, but invain, and also how to pass any varaiable from one dialog box to other plz help me.



Re: Visual C++ General VC++

Ramkrishna Pawar

Can you post more information on what your code is and what is this ".exe as statistical link libraries"

Are you using TCP/IP Sockets






Re: Visual C++ General VC++

Jonathan Caves - MSFT

Ramkrishna Pawar wrote:

Can you post more information on what your code is and what is this ".exe as statistical link libraries"

I suspect that the OP means that they are building a *.exe and statically linking to MFC.






Re: Visual C++ General VC++

Simple Samples

Are you experienced with TCP/IP programming If not, then another possibility is to develop a COM server and client. That could be used between systems using DCOM.

Using the MFC document/view architecture, the data would normally be put in the document, except a dialog based MFC program normally does not have a document. If it were me, I would use a frame window with a CFormView form, but for what you are doing that would either create a program with a lot of unneeded code or you need to be familiar with MFC to develop the program without the extra stuff.

Probably the dialog needs to be modeless. Other than that, it depends on your requirements whether you do your communication in your application class or in the dialog class. If you use the dialog class then the initialization can be done in OnInitDialog. One problem with modeless dialogs, if my memory is correct, si that a modeless (and modal ) dialog can be closed using the x button at the top right and when that is done the OnOk and OnCancel orerrides are not executed; the WM_CLOSE message can be processed for that.






Re: Visual C++ General VC++

Bite Qiu - MSFT

wasim786nasir wrote:
Hello,

I am trying to build a dialog based program to communicate via lan. i am using MFC files ( .exe as statistical link libraries )

i don't know where to put the code of initialization, as my in myprogram i have kept it in app.cpp file but i am not able use the send - recv function from other dialog boxes. I tried to implement it by as global variable, but invain, and also how to pass any varaiable from one dialog box to other plz help me.

Use API libraries(e.g. openGL, plain windows socket APIs) with MFC require a clear understanding of MFC application's structure to be able to put correct code into correct member function of MFC classes. If you don't know where to put the code of initialization, then most likely you don't know where to send, receive and to terminate as well.

Fortunately you have wrapper class for winsock APIs in MFC: CSocket, CAnsycSocket. I believe you will be more happy to use them than plain APIs, following article will help you with how to use them:

Windows Sockets In MFC

good luck

rico






Re: Visual C++ General VC++

Simple Samples

My UDP Send and Receive Using CAsyncSocket is one sample. Most everything is done in the document but a MFC beginner might have difficulty understanding some of what I did.

A dialog program however is much simpler than other MFC programs and therefore my sample won't help much for a dialog program. I had forgotten that the original question asked about a dialog program.