News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Backing up a screen buffer?

Started by omdown, June 02, 2005, 01:56:13 AM

Previous topic - Next topic

omdown

Does anyone have any idea how to back up and restore a screen buffer?  I'm so lost on this, first I thought I would need to copy and paste the entire thing into a text file by reading each character and its attribute and copying it there, but that didn't seem like it was going to work out very well, and now I'm just lost.  I can't even figure out where to start with this.  If anyone could point me in the right direction it would be greatly appreciated.

MichaelW

Is this for a Windows Console app, or a DOS app?
eschew obfuscation

Jeff

i would think it would be a safe bet to say its a windows console app.

if so, i suppose you could use ReadConsoleOutput to "save" it and WriteConsoleOutput to "restore" it.

MichaelW

Jeff,

That is what I thought too, at first. But omdown has another recent post here in the campus that deals with detecting Ctrl+F, and a post in the 16-bit DOS forum that deals with an app that detects Ctrl+F, and is having problems with it.

omdown,

Whether this is a Windows Console app or a DOS app, my suggestion would be the same. Why backup and restore when your application can have multiple screen buffers (or display pages for DOS)? For a Windows Console app instead of backing up the current screen buffer, you could just leave it as is, create a new one, use it for whatever, and then switch back to the previous one. AFAIK you can create as many screen buffers as will fit in the available memory. For a DOS app you would do essentially the same, just switching display pages. Where under DOS or Windows 9x you would typically have 8 display pages available, I seem to recall that Windows 2000 and XP limit the number of display pages to 4.

You have already been shown how to work with display pages. For console screen buffers, take a look at the CreateConsoleScreenBuffer and SetConsoleActiveScreenBuffer functions here:

MSDN: Character Mode Applications
eschew obfuscation