#include <windows.h>
#include <stdio.h>
#include "console.h"

/* Microsoft Developer Support
   Copyright (c) 1992, 1993 Microsoft Corporation */

/*******************************************************************
* FUNCTION: demoConInfo(HANDLE hConOut)                            *
*                                                                  *
* PURPOSE: demonstrate GetConsoleScreenBufferInfo. Get the current *
*          console screen buffer information and display it on the *
*          console.                                                *
*                                                                  *
* INPUT: console handle to output to                               *
*******************************************************************/

void demoConInfo(HANDLE hConOut)
{
  BOOL bSuccess;
  CONSOLE_SCREEN_BUFFER_INFO csbi;
  CHAR szTemp[128];

  setConTitle(__FILE__);
  bSuccess = GetConsoleScreenBufferInfo(hConOut, &csbi);
  PERR(bSuccess, "GetConsoleScreenBufferInfo");
  myPuts(hConOut, "For information on the console buffer, we need to call\n"
                  "GetConsoleScreenBufferInfo. Here is the information from\n"
                  "the buffer returned, the CONSOLE_SCREEN_BUFFER_INFO:");
  sprintf(szTemp, "Size: X = %d, Y = %d", csbi.dwSize.X, csbi.dwSize.Y);
  myPuts(hConOut, szTemp);
  sprintf(szTemp, "Cursor pos: X = %d, Y = %d", csbi.dwCursorPosition.X,
      csbi.dwCursorPosition.Y);
  myPuts(hConOut, szTemp);
  sprintf(szTemp, "Character display attribute: 0x%04x", csbi.wAttributes);
  myPuts(hConOut, szTemp);
  sprintf(szTemp, "Window position: Left = %d, Right = %d, Top = %d, "
      "Bottom = %d", csbi.srWindow.Left, csbi.srWindow.Top,
      csbi.srWindow.Right, csbi.srWindow.Bottom);
  myPuts(hConOut, szTemp);
  sprintf(szTemp, "Maximum window size: X = %d, Y = %d",
      csbi.dwMaximumWindowSize.X, csbi.dwMaximumWindowSize.Y);
  myPuts(hConOut, szTemp);
  myPuts(hConOut, "\nHit enter to return...");
  myGetchar();
  return;
}
