Month
Sample Output

Brief Information about the December 98 CSIG Meeting

General Purpose Timer


Next to my computer at home I have a small electronic kitchen timer that I use periodically to test computer programs or installation procedures. It's often useful to know how long program takes to install. The timer that I have is accurate to one second and this is generally more than adequate for my needs.

I realized how ridiculous is to have a multi-megabuck computer sitting here and needing a separate timer to perform certain tests. Therefore I decided for this month C Users Group meeting, that I would create a software timer that has the same functionality.

The timer is based on Microsoft foundation classes (MFC) and is compiled using Microsoft Visual C++ version 5. There is a large display for numbers over an inch high. Several buttons provide start and stop functions. Extra features of this timer include the ability to start the timer from the command line such as in the middle of a batch program and to an identify the timer so that more than one event can be timed. Just for fun, I wrote a simple batch program that starts 50 timers at once.

"Random Access" questions start at 7:30 Tuesday night. See you there.


You can get the source code and the executable programs from links on C User Group home page: source code and executables will be available directly from the ACGNJ ftp server:

See SOURCE CODE links below.


Sample Code:

	m_digits.GetWindowRect(&digitRect);
	GetWindowRect(&dialogRect);

	ASSERT(0 == dialogRect.left);
	ASSERT(0 == dialogRect.top);

	#define DIG_HEIGHT (digitRect.bottom-digitRect.top)

	m_CFont.CreateFont(DIG_HEIGHT,		// int nHeight, 
			    0,			// int nWidth, 
			    0,			// int nEscapement, 
			    0,			// int nOrientation, 
			    FW_BOLD,		// int nWeight, 
			    0,			// BYTE bItalic, 
			    0,			// BYTE bUnderline, 
			    0,			// BYTE cStrikeOut, 
			    ANSI_CHARSET,	// BYTE nCharSet, 
			    OUT_DEFAULT_PRECIS,	// BYTE nOutPrecision, 
			    CLIP_DEFAULT_PRECIS,// BYTE nClipPrecision, 
			    DEFAULT_QUALITY,	// BYTE nQuality, 
			    DEFAULT_PITCH |	// BYTE nPitchAndFamily, 
			    FF_DONTCARE,
			    "SYSTEM_FONT");	// LPCTSTR lpszFacename );


	m_digits.SetFont(&m_CFont);

	Timer1 = SetTimer(1,1000,NULL);			// init screen update timer
	timerRunning = Hours = Minutes = Seconds = 0;
	id[0] = 0;

	
	GetSystemTime(&m_startTime);
	GetSystemTime(&m_endTime);

	p = GetCommandLine();
	strupr(p);
	if (  strstr(p,"AUTORUN")) timerRunning = 1;
	if (p=strstr(p,"ID="))     strcpy(id,p+3);

	return TRUE;  // return TRUE  unless you set the focus to a control

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ b l a s t . n e t
Back to C++ Main Page