Scroll in win32 console mode

This is a discussion on Scroll in win32 console mode within the C Programming forums, part of the General Programming Boards category; Hi! I have an output of some files and I want to limit the number of lines of display to ...

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Question Scroll in win32 console mode

    Hi!

    I have an output of some files and I want to limit the number of lines of display to 5 lines. If I want to do this I need a scroll, right?

    So, how to make a scroll in win32 console mode?

    I'm writing in VC++ 6.0 on win98.

    Thanks.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    The console window already has scrolling capability, but if you mean you only want five lines to be printed at a time then there are a few ways to do it. The simplest is to take five lines and print them, then wait for the user to ask for five more. A better trick is to create a little animation where you read one line and place it in an array, then print five lines. In the next iteration you move the index forward one element and print five more lines from there. With the proper sleep timing and screen clear, you can create a scrolling effect.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Hm...

    Do you know how to write a code that will not allow user to exceed some X coordinate? Something like this:

    Code:
    ------------------------------                                             
    - user writes something, and -
    - his text must not exceed   -
    - the border of this frame   -
    -                            - 
    -                            -
    ------------------------------
    Last edited by GaPe; 04-28-2002 at 07:01 AM.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    It would require some flavor of gotoxy, but you could keep two indexes. One would be the starting y coordinate and the other would be the ending y coordinate. Every time you print a newline, you increment a counter and if the counter equals the ending coordinate, reset the cursor to the starting position. This is assuming that no word wrap takes place, but that can be dealt with by keeping tabs on the x coordinates as well.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding a console window to a Win32 app
    By VirtualAce in forum Game Programming
    Replies: 7
    Last Post: 02-01-2009, 12:09 PM
  2. making a stealthy win32 console application?
    By killdragon in forum C++ Programming
    Replies: 3
    Last Post: 09-08-2004, 02:50 PM
  3. Win32 Console App
    By Trauts in forum Windows Programming
    Replies: 2
    Last Post: 05-19-2003, 03:42 PM
  4. Console Screen Mode
    By GaPe in forum Windows Programming
    Replies: 9
    Last Post: 02-09-2003, 11:39 AM
  5. Creating fractals in C++ console mode
    By speedy in forum C++ Programming
    Replies: 2
    Last Post: 10-26-2001, 01:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21