C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
WMENUCLK.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* WMENUCLK.C - Demonstrate choosing a menu
 * command with the QuickWin _wmenuclick
 * function
 */
 
#include <io.h>
#include <stdio.h>
 
#define NUMWINS     4    /* Number of windows */
#define OPENFLAGS   "w"  /* Access permission */
 
void main()
{
   int i, nRes;
   int wm;               /* Menu click result */
   int sf, gf;           /* Set/Get focus results */
   FILE *wins[NUMWINS];  /* Array of file pointers */
 
   /* Open NUMWINS windows */
   /* NULL arguments accept default characteristics */
   for( i = 0; i < NUMWINS; i++ )
   {
      wins[i] = _fwopen( NULL, NULL, OPENFLAGS );
      if( wins[i] == NULL )
      {
         printf( "***ERROR: On _fwopen #%i\n", i );
         exit( -1 );
      }
      /* Write in each window */
      nRes = fprintf( wins[i], "Windows!\n" );
   }
 
   /* Tile child windows with _wmenuclick */
   wm = _wmenuclick( _WINTILE );
   if( wm == -1 )
   {
      printf( "***ERROR: _wmenuclick\n" );
      exit( -1 );
   }
 
   /* Pass the focus from window to window */
   for( i = 0; i < NUMWINS; i++ )
   {
      sf = _wsetfocus( _fileno( wins[i] ) );
      gf = _wgetfocus();
      if(( sf == -1 ) || ( gf == -1 )
          || ( gf != _fileno( wins[i] ) ) )
      {
         printf( "***ERROR: _wsetfocus/_wgetfocus\n" );
         exit( -1 );
      }
   }
 
   nRes = _fcloseall();
 
   exit( 0 );
}
                                    -♦-