CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2009
    Posts
    3

    Erasing multiple lines in Windows console

    Hi everyone,

    I have created a Win32 console application. I would like to give the user an indication of the program's progress because my program runs for a long time. I also have multiple progress indicators. However, if I put things on different lines, I can only erase the last line. For example, I want to output this to the user:

    Code:
    3 attempts
    45%
    And I want to keep updating this. But when I try to use \b to erase both of the lines, it only erases the last line. So if I put (cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b" << attempts << endl << progress), it prints out:

    Code:
    3 attempts
    4 attempts
    46%
    How do I erase the first line?

    Thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Erasing multiple lines in Windows console

    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  3. #3
    Join Date
    Feb 2009
    Location
    India
    Posts
    444

    Re: Erasing multiple lines in Windows console

    I'm sure you can do that using the functions SetConsoleCursorPosition and WriteConsole.
    «_Superman
    I love work. It gives me something to do between weekends.

    Microsoft MVP (Visual C++)

  4. #4
    Join Date
    May 2009
    Posts
    3

    Re: Erasing multiple lines in Windows console

    Obviously, I tried searching this up on Google and I found nothing that said anything about erasing multiple lines of text.

  5. #5
    Join Date
    May 2007
    Posts
    811

    Re: Erasing multiple lines in Windows console

    Obviously, You did not try hard enough. Here is good start. Play close attention to SetConsoleCursorPosition function. From this, it should be easy to come up with solution to your problem.

  6. #6
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Erasing multiple lines in Windows console

    The third result down explains exactly the task that you are trying to do...
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured