home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / win / prg / cenviw / barclock.cmm < prev    next >
Text File  |  1994-05-31  |  2KB  |  58 lines

  1. @echo off
  2. // ************************************************************
  3. // *** BarClock.cmm - CEnvi for Windows utility to show the ***
  4. // *** ver.1          current time in the title bar of the  ***
  5. // ***                currently active window.              ***
  6. // ************************************************************
  7.  
  8. #define UPDATE_FREQUENCY   1000 // milliseconds between update
  9.  
  10. // Adjust strftime statement to get your own version of time.
  11. // Uncomment the one you want
  12. //TimeFormat = "%I:%M%p";  // 12-hour and minute and AM or PM
  13. //TimeFormat = "%H:%M:%S"; // 24-hour hour:minute:second
  14. TimeFormat = "%I:%M:%S";   // 12-hour hour:minute:second
  15.  
  16. #include <WinTools.lib>
  17.  
  18. // hide this window
  19. ShowWindow(ScreenHandle(),SW_HIDE);
  20.  
  21. TimeWindow = NULL;
  22.  
  23. while( True ) {
  24.    suspend(UPDATE_FREQUENCY);
  25.    Hwnd = GetActiveWindow();
  26.    if ( Hwnd != TimeWindow ) {
  27.       // New window, so remove time from old window title
  28.       if ( TimeWindow ) {
  29.          if ( Title = GetWindowTitle(TimeWindow) ) {
  30.             RemoveTimeFromTitle(Title);
  31.             SetWindowTitle(TimeWindow,Title);
  32.          }
  33.       }
  34.    }
  35.    if ( TimeWindow = Hwnd ) {
  36.       // Add time to this window
  37.       if ( Title = GetWindowTitle(TimeWindow) ) {
  38.          RemoveTimeFromTitle(Title);
  39.          SetWindowTitle(TimeWindow,AddTimeToTitle(Title));
  40.       }
  41.    }
  42. }
  43.  
  44.  
  45. AddTimeToTitle(pTitle)
  46. {
  47.    strftime(lTime,TimeFormat,localtime(time()));
  48.    sprintf(lTitle,"%s  <%s>",pTitle,lTime);
  49.    return lTitle;
  50. }
  51.  
  52. RemoveTimeFromTitle(pTitle)
  53. {
  54.    if ( (lSequence = strrchr(pTitle,'<'))  &&  strchr(lSequence,'>') )
  55.       lSequence[-2] = '\0';
  56. }
  57.  
  58.