home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / CENVIW9.ZIP / WINTOOLS.CMM < prev    next >
Text File  |  1994-03-08  |  3KB  |  95 lines

  1. //******************************************************************
  2. //*** WinTools.cmm - CEnvi demonstration program to show the     ***
  3. //*** ver.1          capabilities of the WinTools.lib functions. ***
  4. //******************************************************************
  5.  
  6.  
  7. #include <WinTools.lib>
  8.  
  9. printf("Moving CEnvi text window to middle of the screen...");
  10. // Change size of CEnvi window so that it is 1/4 screen height and full width
  11. // and 1/2 of screen width
  12. GetScreenSize(ScreenWidth,ScreenHeight);
  13. SetSize(ScreenHandle(),width = ScreenWidth,height = ScreenHeight / 4);
  14.  
  15. // now center this in the screen
  16. SetPosition(ScreenHandle(),(ScreenWidth - width) / 2,(ScreenHeight - height) / 2);
  17.  
  18. // Start up NotePad
  19. printf("\nStarting notepad...");
  20. if ( IsWindow("notepad") ) {
  21.    printf("\n\n\aERROR: Notepad must NOT be running to run this test.");
  22.    printf("\nPress any key to quit...");
  23.    getch();
  24.    exit(1);
  25. }
  26. if ( -1 == spawn(P_NOWAIT,"NotePad.exe") ) {
  27.    printf("\n\n\aERROR: Cannot start NotePad.exe");
  28.    printf("\nPress any key to quit...");
  29.    getch();
  30.    exit(1);
  31. }
  32.  
  33. // Restore this CEnvi screen as the active one
  34. SetActiveWindow(ScreenHandle());
  35.  
  36. printf("\nPress any key to move NotePad to upper-left corner...");
  37. getch();
  38. SetPosition("notepad",0,0);
  39.  
  40. printf("\nPress any key to move NotePad to bottom-right corner...");
  41. getch();
  42. GetSize("notepad",width,height);
  43. SetPosition("notepad",ScreenWidth - width,ScreenHeight - height);
  44.  
  45. printf("\nPress any key to fit notepad in top center...");
  46. getch();
  47. // make 1/2 width of screen height and width, and center at top
  48. SetSize("notepad",ScreenWidth / 2,ScreenHeight / 2);
  49. SetPosition("notepad",ScreenWidth / 4,0);
  50.  
  51. printf("\nPress any key to hide notepad...");
  52. getch();
  53. ShowWindow("notepad",SW_HIDE);
  54.  
  55. printf("\nPress any key to show notepad...");
  56. getch();
  57. ShowWindow("notepad",SW_SHOWNOACTIVATE);
  58.  
  59. printf("\nPress any key to minimize notepad...");
  60. getch();
  61. ShowWindow("notepad",SW_MINIMIZE);
  62.  
  63. printf("\nPress any key to maximize notepad...");
  64. getch();
  65. ShowWindow("notepad",SW_SHOWMAXNOACTIVE);
  66.  
  67. printf("\nPress any key to restore notepad...");
  68. getch();
  69. ShowWindow("notepad",SW_RESTORENOACTIVE);
  70.  
  71. printf("\n\nFinally, will minimize CEnvi and we're done.");
  72. printf("\nPress any key to change notepad's title...");
  73. getch();
  74. printf("\nKill notepad, or press any key to end this test...");
  75.  
  76. // Make notepad the active window
  77. SetActiveWindow("notepad");
  78. // Minimize this CEnvi window
  79. ShowWindow(ScreenHandle(),SW_MINIMIZE);
  80. // Get notepad's handle because its name will change
  81. NotepadHandle = GetWindowHandle("notepad");
  82.  
  83. // Finally, as long as notepad exists, rotate the advertisement
  84. NewTitle = "  I like CEnvi.    CEnvi is swell!    Thank you, Nombas.  ";
  85. TitleLen = strlen(NewTitle);
  86. while( IsWindow(NotepadHandle)  &&  !kbhit() ) {
  87.    // set to new title
  88.    SetWindowTitle(NotepadHandle,NewTitle);
  89.    // rotate title one character left
  90.    NewLastChar = NewTitle[0];
  91.    strcpy(NewTitle,NewTitle + 1);
  92.    NewTitle[TitleLen-1] = NewLastChar;
  93. }
  94.  
  95.