Annotation of mstools/samples/console/alocfree.c, revision 1.1.1.3

1.1.1.3 ! root        1: 
        !             2: /******************************************************************************\
        !             3: *       This is a part of the Microsoft Source Code Samples. 
        !             4: *       Copyright (C) 1993 Microsoft Corporation.
        !             5: *       All rights reserved. 
        !             6: *       This source code is only intended as a supplement to 
        !             7: *       Microsoft Development Tools and/or WinHelp documentation.
        !             8: *       See these sources for detailed information regarding the 
        !             9: *       Microsoft samples programs.
        !            10: \******************************************************************************/
        !            11: 
1.1       root       12: #include <windows.h>
                     13: #include <stdio.h>
                     14: #include "console.h"
                     15: 
                     16: /*********************************************************************
                     17: * FUNCTION: demoAllocFree(HANDLE hConOld, HANDLE *hConOut)           *
                     18: *                                                                    *
                     19: * PURPOSE: demonstrate FreeConsole & AllocConsole. Free the console  *
                     20: *          and allocate a new one                                    *
                     21: *                                                                    *
                     22: * INPUT: the current console output handle and a temporary 'scratch' *
                     23: *        console handle                                              *
                     24: *********************************************************************/
                     25: 
                     26: void demoAllocFree(HANDLE hConOld, HANDLE *hConOut)
                     27: {
                     28:   BOOL bSuccess;
                     29: 
                     30:   setConTitle(__FILE__);
                     31:   myPuts(hConOld, "Let's free the current console with FreeConsole. It will\n"
                     32:                   "disappear for 3 seconds, then we'll allocate a new one.\n"
                     33:                   "with AllocConsole. Hit return to continue...");
                     34:   myGetchar();
                     35:   bSuccess = FreeConsole();
1.1.1.3 ! root       36:   PERR(bSuccess, "FreeConsole");
1.1       root       37:   Sleep(3000);
                     38:   bSuccess = AllocConsole();
1.1.1.3 ! root       39:   PERR(bSuccess, "AllocConsole");
1.1       root       40:   *hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
                     41:   /* set our console text attribute */
                     42:   bSuccess = SetConsoleTextAttribute(*hConOut, FOREGROUND_CYAN);
                     43:   PERR(bSuccess, "SetConsoleTextAttribute");
                     44:   myPuts(*hConOut, "This is a new console that we've allocated with AllocConsole.");
                     45:   Sleep(2000);
                     46:   /* must refresh the screen since we've replaced the console */
                     47:   showConAPIs(*hConOut);
                     48:   return;
                     49: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.