Click to See Complete Forum and Search --> : Dialog Help
Falhorn
September 22nd, 2005, 05:35 PM
Ok here is my situation, I am modifying an existing project writen in C, which I can't change well I can but for this problem I can't. Its a Win32 Console application and I need to get information from the user or various types, ints, floats, strings, ect. I need to modify the code so it will bring up a dialog box to retrieve the info from the user then when ok is accepted to send back the information to be proccessed.
I am still a student and dialog box useage in a console application is one thing my collage never had us do, let alone MFC programing.... Any help that can be given is most apreciated.
MXPguru
September 23rd, 2005, 05:11 AM
Dialog box in a console application? o_0
I don't think it's possible. (correct me if it is)
Falhorn
September 23rd, 2005, 11:28 AM
exactly my problem :)
Ajay Vijay
September 23rd, 2005, 12:00 PM
Your console application is not linked with USER32.DLL which has almost all GUI components. You could either load it dynamically using LoadLibrary and call appropriate functions like MessageBox[A/W], or you might also link it explicitly using user32.lib as linker input.
I am not sure how the second method will work, but I am quite sure that it will work.
Or you might want to choose this option too: Create another GUI project, and call this from existing program using CreateProcess. Pass the appropriate argument to the GUI-process. Wait until second terminates using WaitForSingleObject on the process handle returned by CreateProcess - this will prevent your old (CUI) process to continue further, until user has given required data.
All the best.
Falhorn
September 24th, 2005, 01:43 AM
I like the idea of using CreateProcess, since it will alow me to create all dialogs in MFC with out haveing to modiy the C code of the origonal project. However schooling has not been as pleasent as I would have liked and have never gone over MFC applications and my High School background on the matter just extends primariy to the interface part not so much the over all code behind it.
So my question is this is how can I return values and send values to and from an MFC application. I want to do is this since I have multiple different types of information types I want the MFC app to handle via different dialogs aka one dialog to get an integer, one a char string, a float extra, so I would like to send the MFC app when CreateProcess starts it say an integer to select which dialog to spawn then to send the information back to the main console program. Where in the MFC app would I be looking for the comandline arguments. And how would I send back infromation, idealisticly of varing types, and where is that in an MFC application?
Ajay Vijay
September 24th, 2005, 05:10 AM
It would be somewhat complex at first, but it is one of the solutions.
Have a named mutex shared among these two (or more) processes. This mutex on caller process (that is CUI process), would work to wait for second process to complete after you issue CreateProcess. You wait on client side using WaitForSingleObject on this mutex, after CreateProcess. The server process (MFC application) will set it signaled and your client process will continue.
Now, data exchange part come into scene. For this you use memory-mapped files using CreateFileMapping and MapViewOfFile APIs. Both of the application will read/write on this shared data.
Let give it a try!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.