Thread: Win32 Console App... multiple console buffers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    417

    Win32 Console App... multiple console buffers

    I want to have multiple consoles in a program, and switch between them.

    So I can have multiple screens the user can swap between by pressing a button... that would be especially useful for debugging.

    Code:
    #include <iostream.h>
    #include <windows.h>
    #include <conio.h>
    
    int main()
    {
    	HANDLE oldConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    	int junk;
    
    	cout << "Old!" << endl;
    
    	getch();
    
    	HANDLE newConsole = CreateConsoleScreenBuffer(GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
    	FreeConsole();
    	cout << "This shouldn't show up" << endl;
    	SetConsoleActiveScreenBuffer(newConsole);
    	system("cls");
    
    	cout << "New!" << endl;
    	getch();
    
    	system("cls");
    	FreeConsole();
    	SetConsoleActiveScreenBuffer(oldConsole);
    	return 0;
    }
    I know I'm not doing this exactly right, but I don't know exactly how to do so.

    I know there is a way to do it with the Console APIs... http://msdn.microsoft.com/library/de..._functions.asp
    Last edited by Trauts; 04-28-2003 at 11:10 AM.

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, 01:09 PM
  2. Replies: 28
    Last Post: 10-30-2008, 03:52 PM
  3. Win32 console, xp,nt,2000 only?
    By Ash1981 in forum C Programming
    Replies: 8
    Last Post: 01-01-2006, 03:09 AM
  4. Multiple toolboxes in an app.
    By Anonymous Cowar in forum Windows Programming
    Replies: 2
    Last Post: 12-03-2002, 03:17 AM
  5. multiple console windows
    By gordy in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-13-2002, 11:05 PM