473,414 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Console and scrolling

Is there any way to stop the console from scrolling? What I mean isnt
to not scroll at all, its that I want to get rid of the buffer. When a
new line is created, I want row 0 to go away permanently, not just be
scrolled out of view. No scroll bars, etc. I know the C# console is
weak, but even via Win32 API?

Nov 17 '05 #1
2 9792
PHead wrote:
Is there any way to stop the console from scrolling? What I mean isnt
to not scroll at all, its that I want to get rid of the buffer. When
a new line is created, I want row 0 to go away permanently, not just
be scrolled out of view. No scroll bars, etc. I know the C# console is
weak, but even via Win32 API?


That's a good question. Generally speaking, a console application has no
influence over how the command shell application behaves, which is what
you're attempting to do. One way to achieve what you want is to create a
two-dimensional array of characters representing the screen:

char screen = new char[Console.WindowHeight, Console.WindowWidth];

Now, do all your printing into a buffer using MemoryStream. When you're
ready, write the stored characters on the virtual screen yourself,
performing your own scrolling. Finally, use Console.SetCursorPosition()
along with normal writing functions to write out the contents of the screen
buffer onto the real console. If you do this each time you need to draw
something on the screen, it should never have a chance to scroll.
Unfortunately, this is probably more work than it's worth. I hope this
helps.
--
Derrick Coetzee, MCP, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included code samples are subject to the terms
specified at http://www.microsoft.com/info/cpyright.htm
Nov 17 '05 #2
PHead wrote:
Is there any way to stop the console from scrolling? What I mean isnt
to not scroll at all, its that I want to get rid of the buffer. When
a new line is created, I want row 0 to go away permanently, not just
be scrolled out of view. No scroll bars, etc. I know the C# console is
weak, but even via Win32 API?


That's a good question. Generally speaking, a console application has no
influence over how the command shell application behaves, which is what
you're attempting to do. One way to achieve what you want is to create a
two-dimensional array of characters representing the screen:

char screen = new char[Console.WindowHeight, Console.WindowWidth];

Now, do all your printing into a buffer using MemoryStream. When you're
ready, write the stored characters on the virtual screen yourself,
performing your own scrolling. Finally, use Console.SetCursorPosition()
along with normal writing functions to write out the contents of the screen
buffer onto the real console. If you do this each time you need to draw
something on the screen, it should never have a chance to scroll.
Unfortunately, this is probably more work than it's worth. I hope this
helps.
--
Derrick Coetzee, MCP, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included code samples are subject to the terms
specified at http://www.microsoft.com/info/cpyright.htm
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Totte Karlsson | last post by:
Hi, How can I print to the console without having it scrolling to a new line for each print statement? I want to print a count down in the console, but for each count it scrolls the screen (of...
8
by: Totte Karlsson | last post by:
Hi, How can I print to the console without having it scrolling to a new line for each print statement? I want to print a count down in the console, but for each count it scrolls the screen (of...
20
by: Brett Hoerner | last post by:
This is a pretty basic, mostly un-python-related question, although I'm asking because of Python. Is there a different shell I can use (other than cmd.com) to run Python in, where I can...
6
by: Kay Schluehr | last post by:
The documentation of the Python console behaviour is not correct anymore for Python 2.4.1. At least for the Win2K system I'm working on 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. ...
0
by: PHead | last post by:
Is there any way to stop the console from scrolling? What I mean isnt to not scroll at all, its that I want to get rid of the buffer. When a new line is created, I want row 0 to go away...
2
by: _R | last post by:
I've got a few apps that were designed to be used via MSDOS window. They make use of the old-style VC++6 Console class for doing writes, cursor repositioning, scrolling, etc. (Unfortunate name...
11
by: sebplays | last post by:
Hi, I seach function for clear screen in VB.Net for console application. Please help me
0
by: Jody L. Whitlock | last post by:
Okay, never have had to do this before, but now I need to make a console application that looks and acts kinda like Linux's NCurses. the colors are not a concern, but the nice menu's and the...
6
by: Mythran | last post by:
Is it possible to attach Windows WndProc hooks into a Console application window? Thanks, Mythran
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.