Automatically Closing QuickWin Exec Window at Completion

ID: Q93661


The information in this article applies to:

In Visual C++, when a QuickWin program completes execution, its window remains open by default so the user can view its output or any other messages that the program displays.

To automatically close the window for a QuickWin program upon completion, call two Windows functions. The first function retrieves the window handle and the second function destroys the window. The following code example demonstrates this technique.

Sample Code


/*
 * Compiler options required: None
 */ 
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
   int hWnd;
   int nChar;
   printf("Generic");
   nChar = getchar();
   if (toupper(nChar) == (int)'C')
      {
      // GetActiveWindow() works only when
      // the QuickWin Exec window is active
      hWnd = GetActiveWindow();
      // Other option: Use FindWindow(). "TEST" is the default
      // QuickWin Exec application name, which is used as the
      // window title.
      // hWnd = FindWindow(NULL, "TEST");
      DestroyWindow(hWnd) ;
      }
   exit(1);
} 

Additional query words: kbinf 1.00 1.50 1.51 1.52


Keywords          : kb16bitonly 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: July 21, 1999