home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / WINTOOLS.CMD < prev    next >
OS/2 REXX Batch file  |  1995-03-30  |  4KB  |  113 lines

  1. EXTPROC CEnvi2
  2. //***************************************************************************
  3. //*** WinTools.cmd - CEnvi2 demonstration program to show the capabilities ***
  4. //*** ver.1          of the WinTools.lib functions.                       ***
  5. //***************************************************************************
  6.  
  7. #include <Pmdll.lib>
  8. #include <WinTools.lib>
  9.  
  10. printf("Moving CEnvi2 text window to middle of the screen...");
  11.  
  12. // Save current dimensions of CEnvi2 window
  13. GetWindowRect(Info().WinHandle,SavePosition);
  14. SaveMaximized = IsMaximized(Info().WinHandle);
  15.  
  16. // Try to change size of CEnvi2 window so that it is 1/4 screen height and full width
  17. // PM might make it LESS than this size
  18. GetScreenSize(ScreenWidth,ScreenHeight);
  19. SetSize(Info().WinHandle,ScreenWidth,ScreenHeight / 4);
  20.  
  21. // Center CEnvi2 window in the screen
  22. GetSize(Info().WinHandle,width,height);
  23. printf("Set to %d %d\n",(ScreenWidth - width) / 2,(ScreenHeight - height) / 2);
  24. SetPosition(Info().WinHandle,(ScreenWidth - width) / 2,(ScreenHeight - height) / 2);
  25.  
  26. // Add lots of lines to make sure we can read the new lines on the screen
  27. for ( i = ScreenSize().row; i; i-- )
  28.    printf("\n");
  29.  
  30. // Start up E.EXE
  31. printf("\nStarting E.EXE...");
  32. if ( IsWindow("e.exe") ) {
  33.    printf("\n\n\aERROR: E.EXE must NOT be running to run this test.");
  34.    printf("\nPress any key to quit...");
  35.    getch();
  36.    exit(1);
  37. }
  38. system("Start /F /N E.EXE");
  39. // Wait for e.exe to exist
  40. while ( !IsWindow("e.exe") )
  41.    suspend(100);
  42.  
  43. // Restore this CEnvi2 screen as the active one
  44. SetActiveWindow(Info().WinHandle);
  45.  
  46. printf("\nPress any key to move E.EXE to upper-left corner...");
  47. getch();
  48. GetSize("e.exe",width,height);
  49. SetPosition("e.exe",0,ScreenHeight - height);
  50.  
  51. printf("\nPress any key to move E.EXE to bottom-right corner...");
  52. getch();
  53. SetPosition("e.exe",ScreenWidth - width,0);
  54.  
  55. printf("\nPress any key to fit E.EXE in top center...");
  56. getch();
  57. // make 1/2 width of screen height and width, and center at top
  58. SetSize("e.exe",ScreenWidth / 2,ScreenHeight / 2);
  59. SetPosition("e.exe",ScreenWidth / 4,ScreenHeight / 2);
  60.  
  61.  
  62. printf("\nPress any key to hide E.EXE...");
  63. getch();
  64. ShowWindow("e.exe",SW_HIDE);
  65.  
  66. printf("\nPress any key to show E.EXE...");
  67. getch();
  68. ShowWindow("e.exe",SW_SHOWNOACTIVATE);
  69.  
  70. printf("\nPress any key to minimize E.EXE...");
  71. getch();
  72. ShowWindow("e.exe",SW_MINIMIZE);
  73.  
  74. printf("\nPress any key to maximize E.EXE...");
  75. getch();
  76. ShowWindow("e.exe",SW_SHOWMAXNOACTIVE);
  77.  
  78. printf("\nPress any key to restore E.EXE...");
  79. getch();
  80. ShowWindow("e.exe",SW_RESTORENOACTIVE);
  81.  
  82. printf("\nDemo done, but E.EXE needs a new title.");
  83. printf("\nTerminate E.EXE, or press key here to exit....");
  84.  
  85. // Make e.exe the active window
  86. SetActiveWindow("e.exe");
  87.  
  88. // Will change the title, so save the window handle here
  89. EHandle = GetWindowHandle("e.exe");
  90.  
  91. // Finally, as long as e.exe exists, rotate the advertisement
  92. NewTitle = "  I like CEnvi.    CEnvi is swell!    Thank you, Nombas.  ";
  93. TitleLen = strlen(NewTitle);
  94. while( IsWindow(EHandle)  &&  !kbhit() ) {
  95.    // set to new title
  96.    SetWindowTitle(EHandle,NewTitle);
  97.    // rotate title one character left
  98.    NewLastChar = NewTitle[0];
  99.    strcpy(NewTitle,NewTitle + 1);
  100.    NewTitle[TitleLen-1] = NewLastChar;
  101.    suspend(100);
  102. }
  103.  
  104. // Restore dimensions of CEnvi2 window
  105. printf("\nbye bye");
  106. if ( SaveMaximized )
  107.    ShowWindow(Info().WinHandle,SW_SHOWMAXNOACTIVE);
  108. SetWindowRect(Info().WinHandle,SavePosition);
  109.  
  110. // If window is still running then close it
  111. CloseWindow(EHandle);
  112.  
  113.