Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Hooking up a GUI to a console application

Reply
Thread Tools

Hooking up a GUI to a console application

 
 
Bobrick
Guest
Posts: n/a
 
      01-17-2007
Hi.

I'm trying to create a GUI for a console application I have (written by
someone else, but with permission to use it). The console application
gathers MIDI data from a port, and returns the data in the form of an
std::vector<unsigned char>.

What I need to do is get this console application to trigger different
buttons to light up on a GUI depending on the contents of the
std::vector<unsigned char> (which is called "message"), but the console
application depends on being called forever, or until the user hits a
key to cancel.

My problem is, I'm not sure how to have the function loop forever
without crashing the application, or alternatively I need to know how I
can have a key press stop the function doing what its doing and go back
to being idle.

Can anyone point me in the right direction?

 
Reply With Quote
 
 
 
 
John Carson
Guest
Posts: n/a
 
      01-17-2007
"Bobrick" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com
> Hi.
>
> I'm trying to create a GUI for a console application I have (written
> by someone else, but with permission to use it). The console
> application gathers MIDI data from a port, and returns the data in
> the form of an std::vector<unsigned char>.
>
> What I need to do is get this console application to trigger different
> buttons to light up on a GUI depending on the contents of the
> std::vector<unsigned char> (which is called "message"), but the
> console application depends on being called forever, or until the
> user hits a key to cancel.
>
> My problem is, I'm not sure how to have the function loop forever
> without crashing the application, or alternatively I need to know how
> I can have a key press stop the function doing what its doing and go
> back to being idle.
>
> Can anyone point me in the right direction?



This is not covered by standard C++ and you should ask in a newsgroup
concerned with the platform you are targeting.

The simplest approach is probably to create two threads; one would run the
console code largely unchanged and the other would run the GUI. Then you
just have to choose one of several approaches for communicating between the
two threads.

--
John Carson


 
Reply With Quote
 
 
 
 
Michael DOUBEZ
Guest
Posts: n/a
 
      01-17-2007
Bobrick a écrit :
> Hi.
>
> I'm trying to create a GUI for a console application I have (written by
> someone else, but with permission to use it). The console application
> gathers MIDI data from a port, and returns the data in the form of an
> std::vector<unsigned char>.
>
> What I need to do is get this console application to trigger different
> buttons to light up on a GUI depending on the contents of the
> std::vector<unsigned char> (which is called "message"), but the console
> application depends on being called forever, or until the user hits a
> key to cancel.
>
> My problem is, I'm not sure how to have the function loop forever
> without crashing the application, or alternatively I need to know how I
> can have a key press stop the function doing what its doing and go back
> to being idle.
>
> Can anyone point me in the right direction?


Sure, the door is just here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Now concerning your problem that depends on the design of the program,
on which OS it runs and how should the final product be working.

The usual solution when using such an external program is to start it in
a thread and parsing I/O for command if needed. If you have POSIX
implmentation of popen, the pstream library is a good stating point.
http://pstreams.sourceforge.net/


Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting a GUI application out of an console application Fabian Steiner Python 1 07-17-2006 05:01 PM
Hooking things up in GUI application Ryan Ginstrom Python 5 04-25-2006 04:24 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Serge Terekhoff Python 0 06-30-2003 12:36 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Egor Bolonev Python 0 06-30-2003 10:43 AM
Re: console mp3->wav decoder for $indows or GUI one which supports console Ben Finney Python 2 06-30-2003 05:43 AM



Advertisments