home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 371_01 / windosio.c < prev    next >
Text File  |  1991-12-26  |  2KB  |  78 lines

  1. /***************************************************************************
  2. *  WinDosIO WinMain Module - By compiling this module and linking with your
  3. *  DOS application in C or C++, most DOS applications can be run under
  4. *  Microsoft Windows with no changes at all(The header file WinDosIO.h
  5. *  should be included to eliminate warnings and even potential errors
  6. *  if not compiling with the large model!)
  7. *  For WinDOSIO Version 2.0 BETA
  8. *  Copyright Graubart-Cervone Software 1991,1992
  9. *****************************************************************************/
  10. #include <windows.h>
  11. #include <string.h>
  12.  
  13. #include <WinDosIO.h>
  14.  
  15.  
  16. #define MAXARGS 16
  17.  
  18. #define MAX_CMDLINE 128
  19.  
  20. int pascal WinMain(HANDLE hInstance, HANDLE hPrevInstance,
  21.            LPSTR lpszCmdline, int cmdshow)
  22.  
  23.  {
  24.     struct CWS cws;
  25.     struct CWS far *cwsP;
  26.     char cmdLineBuffer[MAX_CMDLINE];
  27.     HWND hwnd;
  28.     MSG msg;
  29.     RECT r;
  30.     char *argv[MAXARGS];
  31.     int argc;
  32.     short i;
  33.  
  34.     /* Adapt to any memory model */
  35.     for (i = 0; i < MAX_CMDLINE; i++)
  36.         if (!(cmdLineBuffer[i] = *lpszCmdline++)) break;
  37.       /* Initialize terminal IO */
  38.     WinDosIO(WD_INIT,hInstance,0);
  39.     WinDosIO(WD_REGISTER_WINDOW,hPrevInstance,0);
  40.     hwnd = WinDosIO(WD_CREATE_MAIN_WINDOW,cmdshow,
  41.                     (long)((LPSTR)"WinDosIO"));
  42.  
  43.     GetClientRect(hwnd,&r);
  44.  
  45.  
  46.     cws.cwsTop = r.top;
  47.     cws.cwsLeft = r.left;
  48.     cws.cwsXSize = r.right - r.left;
  49.     cws.cwsYSize = r.bottom - r.top;
  50.     cws.cwsTitle = "";
  51.     cws.cwsFlags = 0;
  52.     cwsP = &cws;
  53.     WinDosIO(WD_CREATE_CHILD_WINDOW,0,(unsigned long)cwsP);
  54.     argv[0] = "WinDosIO";
  55.     if (argv[argc=1] = strtok(cmdLineBuffer," "))
  56.        for (argc = 2; argc < MAXARGS; argc++)
  57.         if (!(argv[argc] = strtok(NULL," "))) break;
  58.  
  59.     main(argc,argv);
  60.  
  61.  
  62.  
  63.     /* Use WinDosIO(WD_DESTROY,hwnd, 0); to terminate application
  64.        without having to click on system close icon.
  65.     */
  66.  
  67.     while( GetMessage( &msg, 0, 0, 0 ) != 0 )
  68.          {
  69.         TranslateMessage( &msg );
  70.         DispatchMessage( &msg );
  71.          }
  72.  
  73.     return 0;
  74.  }
  75.  
  76.  
  77.  
  78.