|
|
1.1 root 1: #include <windows.h>
2: #include <stdio.h>
3: #include "console.h"
4:
1.1.1.2 ! root 5: /* Microsoft Developer Support
! 6: Copyright (c) 1992 Microsoft Corporation */
! 7:
1.1 root 8: /*********************************************************************
9: * FUNCTION: demoAllocFree(HANDLE hConOld, HANDLE *hConOut) *
10: * *
11: * PURPOSE: demonstrate FreeConsole & AllocConsole. Free the console *
12: * and allocate a new one *
13: * *
14: * INPUT: the current console output handle and a temporary 'scratch' *
15: * console handle *
16: *********************************************************************/
17:
18: void demoAllocFree(HANDLE hConOld, HANDLE *hConOut)
19: {
20: BOOL bSuccess;
21:
22: setConTitle(__FILE__);
23: myPuts(hConOld, "Let's free the current console with FreeConsole. It will\n"
24: "disappear for 3 seconds, then we'll allocate a new one.\n"
25: "with AllocConsole. Hit return to continue...");
26: myGetchar();
27: bSuccess = FreeConsole();
28: if (!bSuccess)
29: Beep(600, 500); /* can't output an error message now! */
30: Sleep(3000);
31: bSuccess = AllocConsole();
32: if (!bSuccess)
33: Beep(600, 500);
34: *hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
35: /* set our console text attribute */
36: bSuccess = SetConsoleTextAttribute(*hConOut, FOREGROUND_CYAN);
37: PERR(bSuccess, "SetConsoleTextAttribute");
38: myPuts(*hConOut, "This is a new console that we've allocated with AllocConsole.");
39: Sleep(2000);
40: /* must refresh the screen since we've replaced the console */
41: showConAPIs(*hConOut);
42: return;
43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.