home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / C_PLUS / CNVLIB2 / DOWINFAX.CMD < prev    next >
Encoding:
Text File  |  1994-08-10  |  3.7 KB  |  140 lines

  1. @echo OFF
  2. REM ******************************************************************
  3. REM *** DoWinFax.cmd - Control WINFAX that is running in a Windows ***
  4. REM *** ver.2          session that is controlled by the CEnvi     ***
  5. REM ***                for Windows script WinSpawn.cmm that is     ***
  6. REM ***                running under the name: WINFAX:             ***
  7. REM ******************************************************************
  8.  
  9. CEnvi %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9
  10. GOTO CENVI_EXIT
  11.  
  12. #include <WinSpawn.lib>
  13.  
  14. FullPathName;
  15.  
  16. main(argc,argv)
  17. {
  18.    FullPathName = FullPath(argv[0]);
  19.  
  20.    success = True;
  21.    if ( 2 == argc ) {
  22.       if ( !stricmp("START",argv[1]) )
  23.          SpawnCode(FullPathName,"START",True);
  24.       else if ( !stricmp("END",argv[1]) )
  25.          SpawnCode(FullPathName,"MENU",True,`SelectSystemMenuItem("Close");`);
  26.       else if ( !stricmp("GOIDLE",argv[1]) )
  27.          SpawnCode(FullPathName,"DDE",True,`Execute('["GoIdle"]');`);
  28.       else if ( !stricmp("GOACTIVE",argv[1]) )
  29.          SpawnCode(FullPathName,"DDE",True,`Execute('["GoActive"]');`);
  30.       else
  31.          success = False;
  32.    } else if ( 3 == argc ) {
  33.       if ( !stricmp("MENU",argv[1]) ) {
  34.          sprintf(MenuCode,"SelectMenuItem(\"%s\");",argv[2]);
  35.          SpawnCode(FullPathName,"MENU",True,MenuCode);
  36.       } else if ( !stricmp("SYSMENU",argv[1]) ) {
  37.          sprintf(MenuCode,"SelectSystemMenuItem(\"%s\");",argv[2]);
  38.          SpawnCode(FullPathName,"MENU",True,MenuCode);
  39.       } else
  40.          success = False;
  41.    } else {
  42.       success = False;
  43.    }
  44.    if ( !success ) {
  45.       printf("\aUnrecognized command.\n");
  46.       Instructions();
  47.    }
  48. }
  49.  
  50.  
  51. Instructions()
  52. {
  53.    puts(``)
  54.    puts(`DoWinFax - Control WINFAX through WinSpawn.cmm WINFAX session`)
  55.    puts(``)
  56.    puts(`SYNTAX: DoWinFax <command>`)
  57.    puts(``)
  58.    puts(`WHERE: command may be:`)
  59.    puts(`         START - Start winfax running minimized`)
  60.    puts(`         END - End winfax`)
  61.    puts(`         GOIDLE - Tell WINFAX to go idle via DDE`)
  62.    puts(`         GOACTIVE - Tell WINFAX to go active via DDE`)
  63.    puts(`         MENU <command> - Send WINFAX menu command`)
  64.    puts(`         SYSMENU <command> - Send WINFAX system menu command`)
  65.    puts(``)
  66.    puts(`NOTE: CEnvi for Windows WINSPAWN must be running WINFAX session, example:`)
  67.    puts(`       start /WIN F:\CENVIW\CEnvi.exe E:\CENVI2\WinSpawn.cmm WINFAX 1500`)
  68.    puts(``)
  69. }
  70.  
  71. SpawnCode(pSourceFile,pSourceKey,pWait,pCode)
  72. {
  73.    sprintf(SpawnCmd,
  74.            "CEnvi #include '%s,,,*** %s BEGIN ***,*** %s END ***'\n"
  75.            "%s\n",
  76.            pSourceFile,pSourceKey,pSourceKey,
  77.            3 < va_arg() ? pCode : "");
  78.    WinSpawn("WINFAX",pWait ? WIN_SPAWN_WAIT : WIN_SPAWN,
  79.             SpawnCmd);
  80. }
  81.  
  82. :CENVI_EXIT
  83. GOTO DOWINFAX_EXIT
  84.  
  85. *** START BEGIN ***
  86.  
  87.    #include "WinExec.lib"
  88.    #define EXECUTE_NAME    "FAXMNG"
  89.    WinExec(EXECUTE_NAME,SW_MINIMIZE);
  90.  
  91. *** START END ***
  92.  
  93.  
  94. *** MENU BEGIN ***
  95.  
  96.    #include "WinTools.lib"
  97.    #include "MenuCtrl.lib"
  98.  
  99.    #define WINDOW_TITLE "WINFAX"
  100.  
  101.    SelectMenuItem(item)
  102.    {
  103.       if ( Hwnd = GetWindowHandle(WINDOW_TITLE) ) {
  104.          MenuCommand(Hwnd,item);
  105.       }
  106.    }
  107.  
  108.    SelectSystemMenuItem(item)
  109.    {
  110.       if ( Hwnd = GetWindowHandle(WINDOW_TITLE) ) {
  111.          SystemMenuCommand(Hwnd,item);
  112.       }
  113.    }
  114.  
  115. *** MENU END ***
  116.  
  117.  
  118. *** DDE BEGIN ***
  119.  
  120.    #include "DDEcli.lib"
  121.  
  122.    #define APPLICATION  "FAXMNG"
  123.    #define TOPIC        "CONTROL"
  124.  
  125.    Execute(command)
  126.    {
  127.       // initialize DDE connection
  128.       dde.Application = APPLICATION;
  129.       dde.Topic = TOPIC;
  130.       if ( ConnectToServer(dde) ) {
  131.          DdeExecute(dde,command);
  132.          DisConnectFromServer(dde);
  133.       }
  134.    }
  135.  
  136. *** DDE END ***
  137.  
  138.  
  139. :DOWINFAX_EXIT
  140.