Thread: Scrolling The Text

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

    Question Scrolling The Text

    Hi!

    I want to write a scroll text function for a console mode application for win32 but I have no idea how to do that. This scroll function should be the same as it is in windows. I need some tips and ideas how to write a scroll funtion.

    Example:
    Code:
    -------------------------------------------
    (line 1)- text text text text text    UP    
    (line 2)-sdfsdfsdfsdfsdfsdfsdfsdf
    (line 3)-sdfsdfsdfsdfsdfsdfsdfsdf
    (line 4)-dsfsdfsdfsdfdsfsdfsdfsdf
    (line 5)-dsfsdfdsfdfdfdfdfdfdfdfdf
    (line 6)-dfdfdfdfdfdfdfdfdfdfdfdfdf
    (line 7)-fdddddddddddddddddd         DOWN
    -------------------------------------------
    Now, when I'll press the DOWN button the (line 8) will appear and (line 1) will disappear. If i press UP button (line 8) will disappear and (line 1) will appear. Get it?!

    How to do that ???

    I'm using VC++ .NET on WinXP.

    And thank you in advance for your help.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You could store all lines in an array, called say "lines", which would have 8 indexes.
    >lines[8];
    Then, simply have an int that represents the first array index to be displayed (called Top), and another denoting the number of lines to be displayed (ScreenSize). When the users presses up/down, change the value of the Top, and redraw.

    Code:
    lines[8] = {"line1","line2", "line3", "line4", "line5", "line6", "line7", "line8"};
    int Top = 0;
    int ScreenSize=7;
    DrawScreenLabel:
    ClearScreen;
    Loop Counter From Top To (Top+ScreenSize)
        Printf lines[Counter];
    End Loop
    If UserInput = UP Top--;
    If UserInput = DOWN Top++;
    Goto DrawScreenLabel;
    A certain amount of validation will be needed to ensure you stick within the array bounds, so be careful! And don't use a goto, like in my pseudo code
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    Thank you for replying on my thread. You've been very helpful to me.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by GaPe
    Thank you for replying on my thread. You've been very helpful to me.
    No problem
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scrolling in a text buffer
    By Kode Kid in forum C Programming
    Replies: 3
    Last Post: 07-17-2005, 03:35 PM
  2. Replies: 3
    Last Post: 05-25-2005, 01:50 PM
  3. Scrolling Text
    By fushigidane in forum C++ Programming
    Replies: 4
    Last Post: 01-04-2004, 11:43 AM
  4. Replies: 1
    Last Post: 07-13-2002, 05:45 PM
  5. Ok, Structs, I need help I am not familiar with them
    By incognito in forum C++ Programming
    Replies: 7
    Last Post: 06-29-2002, 09:45 PM