Hooking up a GUI to a console application

Discussion in 'C++' started by Bobrick, Jan 17, 2007.

  1. Bobrick

    Bobrick Guest

    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?
     
    Bobrick, Jan 17, 2007
    #1
    1. Advertising

  2. Bobrick

    John Carson Guest

    "Bobrick" <> wrote in message
    news:
    > 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
     
    John Carson, Jan 17, 2007
    #2
    1. Advertising

  3. 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-lite/how-to-post.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
     
    Michael DOUBEZ, Jan 17, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    1,001
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    491
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    651
    Serge Terekhoff
    Jun 30, 2003
  4. Ryan Ginstrom

    Hooking things up in GUI application

    Ryan Ginstrom, Apr 25, 2006, in forum: Python
    Replies:
    5
    Views:
    500
    sturlamolden
    Apr 25, 2006
  5. Fabian Steiner
    Replies:
    1
    Views:
    622
    faulkner
    Jul 17, 2006
Loading...

Share This Page