text marquee

I have the code to make the text roll. But the problem is that the application can't execute other instructions coz its busy in the infinite loop of the marquee. How do i make the application to execute its normal instructions as well as roll the text simultaneously
Last edited on
You could try including function calls to the other instructions inside of the infinite loop. That would allow you to do just about anything, although you would have to have some system of telling the loop when it is or is not appropriate to call each function.
but that would be as if i am running the code of the application from the loop, whereas the marquee should be just a visual element of the application, and if suppose i have a class 'marquee', then this solution just wont work. Probably the solution is related to multi-threading. e.g.http://www.cplusplus.com/forum/unices/104323
Last edited on
Is this a console application?
yes.
Like I said, you just run it in an infinite loop, and have the loop poll the different functions to see if anything needs to be updated. It wouldn't really be that difficult to do, and you wouldn't have to jump into the threading.
something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

void marquee()
{
       const string text = "Hello World!";
       string outText = text;
       while (true)
       {
                //output outText
                //change the text one char position ex. ello World!  
                //Delay a bit. You don't want it to go too fast. :)
                //clear the screen
                // you will want some kind of exit statement
       }
}

If you want to use threading, c++11 makes it easy with std::thread
Just #include <thread>


Example:
1
2
3
4
5
6
7
int main()
{
       thread tmarqueethread(marquee); //marquee is a function that you are assigning the thread to
       //Do whatever
       return 0;
}
Topic archived. No new replies allowed.