![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Posts: 3
Rep Power: 0
![]() |
Creating GUI
Hello I am new in this forum.
I am currently trying to create a GUI (graphical user interface) to act as a front end for a number of other applications using C++. The requirements for this is that the GUI is able to start up the other applications and interact with them through the command line. I am not sure how to do this. Could anybody point me to a website which gives advice on this. I understand the basics of how the command line works ie that when a programme starts it can receive varaibles from the command line and often when a programme ends it returns variable to the command line like: return 0; } But beyond this I do not know much else. How do you code a programme to interact with anouther programme. for example: start paint.exe and instruct it to load a specfic file. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() ![]() |
For GUI development in C++, I'm leaning more towards wxWidgets these days.
"paint" is deprecated on my box, I have "pbrush" (which is basically the same thing)... To open an image as soon as pbrush is loaded, just pass the image filename in as a parameter to the command. c:\start pbrush "c:\images\myImage.png"
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I just answered the GUI question in this thread.
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Mar 2006
Posts: 3
Rep Power: 0
![]() |
Infinite Recursion
I am not really asking about the GUI. That was just to put my project in context. I know most of how to create a GUI. What I really want to know is how to: pass the image (or any other) filename in as a parameter to the command. Do you know of any good websites that explain all the aspects of what you can do with the "command line" and perhaps provide some examples and tutorials as well? Using the C++ language. |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
When you write the main function, you'll often write it like this:
int main ()
{
...
}While correct, that's shorthand for this: int main (int argc, char* argv[])
{
...
}You have two variables here, argc and argv. The former is the number of parameters you pass to the application, and the latter the parameters themselves. Put another way, if we start our program like this: program.exe My name "is Fred" That's all a bit abstract, so we'll write a program to demonstrate. Compile and run this - call it "params.exe" or something: #include <iostream>
int main (int argc, char* argv[])
{
std::cout << "argc = " << argc << std::endl << std::endl;
for (int i = 0; i < argc; i++)
{
std::cout << "argv[" << i << "] = " << argv[i] << std::endl;
}
}![]() |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Mar 2006
Posts: 3
Rep Power: 0
![]() |
Not exactly what I was looking for.
Thanks Ooblo
But I already knew how to do that. I know how you can start a program and pass a number of parameters to it via the command line from the Dos prompt as you have demonstrated. I also know that when a program shuts down it can pass parameters back to the command line. e.g. int main(void) { int x =3; return x; } What I really want to know is how to code a program so that it sents parameters to the command line without having to shut down. Some sort of function call. Also how to code a program to read messages off the command line after the program was started running. void main (void) { code to send to command line: (program.exe My name "is Fred") code to read from command line: ("whatever happons to be on command line") } |
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
What you're asking for is a means of communicating with a running program. That is not achieved via any form of command line. A program accesses data on a command line when it starts, and there is no trivial way to change that command line and force the running program to reread it. There is also no trivial way that a program can change it's command line, and use that to communicate with some other program (eg the shell that started it).
To achieve what you want, you need to use some means of interprocess communication, and both programs need to be designed to allow that. Let's say that program A starts program B, and wants to exchange data with program B. A simple option would be for program A to write a data file while Program B periodically checks if that file exists and, if the file exists, reads it and then deletes it. If program B wants to send data back to program A, it can use the same technique (probably with a different filename), and program A needs to poll for and read that file. Other means of interprocess communication include sockets, mailboxes, dedicated windows messages (eg WM_COPYDATA), etc. But one common feature of all of them; if you want two programs to communicate, BOTH programs need to be specifically designed to cooperate. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
thanks for explaining what a GUI was, i had no fucking idea until you showed up. when main returns 0, it does that for a reason, older programs that suck return a value to the operating system for error codes, if you've documented what error 319 might be, then you'll know something about your app when it runs.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|