Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Please provide an example of how to display the system time in CNiNumEdit.

I need to display elapsed time in a numeric edit control. The value must be a double. Using MFC, please show me an example that displays the system time in a CNiNumEdit control.
0 Kudos
Message 1 of 3
(3,338 Views)
The trick is to set the FormatString of the num edit control to a format that displays dates/times and to use the COleDateTime class to handle converting the date/time to a double. COleDateTime encapsulates time stored as a DATE, which is a typedef for double. COleDateTime uses the same conversion factor for date/time as what the num edit expects, and since it supports a conversion operator to a DATE, which is really a double, and the num edit Value property is a double, displaying the current time in a num edit can be as simple as this:

// Assuming you have a member variable called m_numEdit for a CNiNumEdit
m_numEdit.FormatString = _T("hh:nn:ss");
m_numEdit.Value = COleDateTime::GetCurrentTime();

Hope this helps.

- Elton
Message 2 of 3
(3,338 Views)
That was fast.

Thank you very much.
0 Kudos
Message 3 of 3
(3,338 Views)