CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2009
    Posts
    1,355

    [RESOLVED] clear the console

    i'm see the console functions, but i can't find the right function for clear the console

    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    instead use: "system("cls");"

    any advice?

  2. #2
    Join Date
    Apr 2009
    Posts
    1,355

    Re: clear the console

    resolved:
    Code:
    //clear the Console
    	void Clear()
    	{
    		 // home for the cursor
          COORD coordScreen = {0, 0};
          DWORD cCharsWritten;
          CONSOLE_SCREEN_BUFFER_INFO csbi;
          DWORD dwConSize;
         
          // Get the number of character cells in the current buffer
          if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
                return;
          dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
         
          // Fill the entire screen with blanks
          if(!FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), (WCHAR)' ', dwConSize, coordScreen, &cCharsWritten))
                return;
         
          // Get the current text attribute.
          if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
                return;
         
          // Set the buffer's attributes accordingly.
          if(!FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
                return;
         
          // Put the cursor at its home coordinates.
          SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordScreen);
    	}
    thanks for all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured