home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
win
/
prg
/
cenviw
/
barclock.cmm
< prev
next >
Wrap
Text File
|
1994-05-31
|
2KB
|
58 lines
@echo off
// ************************************************************
// *** BarClock.cmm - CEnvi for Windows utility to show the ***
// *** ver.1 current time in the title bar of the ***
// *** currently active window. ***
// ************************************************************
#define UPDATE_FREQUENCY 1000 // milliseconds between update
// Adjust strftime statement to get your own version of time.
// Uncomment the one you want
//TimeFormat = "%I:%M%p"; // 12-hour and minute and AM or PM
//TimeFormat = "%H:%M:%S"; // 24-hour hour:minute:second
TimeFormat = "%I:%M:%S"; // 12-hour hour:minute:second
#include <WinTools.lib>
// hide this window
ShowWindow(ScreenHandle(),SW_HIDE);
TimeWindow = NULL;
while( True ) {
suspend(UPDATE_FREQUENCY);
Hwnd = GetActiveWindow();
if ( Hwnd != TimeWindow ) {
// New window, so remove time from old window title
if ( TimeWindow ) {
if ( Title = GetWindowTitle(TimeWindow) ) {
RemoveTimeFromTitle(Title);
SetWindowTitle(TimeWindow,Title);
}
}
}
if ( TimeWindow = Hwnd ) {
// Add time to this window
if ( Title = GetWindowTitle(TimeWindow) ) {
RemoveTimeFromTitle(Title);
SetWindowTitle(TimeWindow,AddTimeToTitle(Title));
}
}
}
AddTimeToTitle(pTitle)
{
strftime(lTime,TimeFormat,localtime(time()));
sprintf(lTitle,"%s <%s>",pTitle,lTime);
return lTitle;
}
RemoveTimeFromTitle(pTitle)
{
if ( (lSequence = strrchr(pTitle,'<')) && strchr(lSequence,'>') )
lSequence[-2] = '\0';
}