Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Console Application to GUI 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I have a console application that obviously uses the parameters the user inputs on the command line.

I want to move this to a GUI application and have the user enter in the same information in an edit box on the GUI.

In my console application, I am looking at the number of parameters using int argc in the main function as well as the pointer to the arguments (argv). How can I do the same thing in a GUI?

Thanks

fergmj
 
It runs in my mind that you can but I can't find my notes. James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.
[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
In the a BCB-application i use "_argv[]" and "_argc" with the desired result, there might be more fancy ways of doing it but it works exactly like in ANSI C...... Totte
 
Totte -

Can you give me an example of HOW you use this?

Thanks

 
I'll try:
Say You call your program ("c:\test\TEST.EXE") in the following way:
"TEST.EXE Test Data 1"
then _argc would be 3 (3 EXTRA parameters, 'Test', 'Data' and '1') and _argv[1] would point on 'Test', _argv[2] points on 'Data' and so forth. _argv[0] always points on 'c:\test\TEST.EXE'!
These _argc and _argv[] can be used in the whole project as they comes from the main project file.

Anything unclear? Totte
 
I understand what you are doing, but are you using the parameters from the main function? I need to make this a GUI so how can I pull the command line into a regular Windows application?

Thanks
 
If i understand you correct you ask HOW to place the extra parameters when calling the application.

You can do so by a shortcut which you edit by right-clicking it and edit the callstring from "c:\test\test.exe" to "c:\test\test.exe Test Data 1".

I'm certain that it can be done from a program calling the application but i have never tried it, i do believe that the execution call can point on parameters to attach but ask others about that or look in the help. Totte
 
char commandlinebuff [50]; // declared as global
strcpy (commandlinebuff,ParamStr(1).c_str ());

ParamStr(0) = argv [0]
ParamStr(1) = argv [1]
ParamStr(2) = argv [2]
ParamStr(3) = argv [3]
etc...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top