Skip to main content
www.olaf-groeger.de

Main navigation

  • Home
  • NMR
  • Programming
    • Streams
    • Subclassing of edit controls
  • Software
    • Calimah Scheduler
    • ServicesCtl

Breadcrumb

  1. Home
  2. Programming
  3. Streams
  4. Console Window For GUI-based Windows Applications
  5. Implementation of The Output Method That Writes Into The Console Window

Implementation of the output method that writes into the console window

By olaf , 30 June 2025

The methods WriteToConsole and WriteCharToConsole call the windows API method WriteConsole and reset the output buffer.

void OG_constreambuf::WriteToConsole()
{
  DWORD dwCharsToWrite = pptr() - pbase();
  DWORD dwCharsWritten;

  if (pbase() != pptr())
  {
    WriteConsole(hConsoleOut, pReserve, dwCharsToWrite,
      &dwCharsWritten, NULL);

    setp(pbase(), epptr());
  }
}

void OG_constreambuf::WriteCharToConsole(int c)
{

  DWORD dwCharsWritten;
  int c1 = c;
  WriteConsole(hConsoleOut, &c1, 1, &dwCharsWritten, NULL);
}

Book traversal links for 3

  • Derivation of the inner class from std::streambuf
  • Up
  • Overriding the methods of the base class streambuf that are called when output should be written

Language switcher

  • English
  • German
Powered by Drupal