Re: Display System Time running real time

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



CTime t;
t.GetCurrentTime();
CString s = t.Format(_T("%H:%M:%S etc..."));
CString old;
c_TimeDisplay.GetWindowText(old);
if(old != s)
c_TimeDisplay.SetWindowText(s);

put this in an OnTimer handler with a 1sec timer interval.

Note that this is not locale-sensitive. To create code that handles locale-sensitive
display, take a look at my Locale Explorer. If you don't care, you can figure out the
display options by using my CTime Explorer. These can all be downloaded from my MVP Tips
site.
joe
On Thu, 4 Dec 2008 16:58:24 -0800 (PST), "aloha826@xxxxxxxxx" <aloha826@xxxxxxxxx> wrote:

Hi

how to display the system date time running real time in Dialog,
including seconds ?

I know declaring like:
SYSTEMTIME systime;
ZeroMemory(&systime,sizeof(SYSTEMTIME));
GetSystemTime(&systime); // gets current time


then access the SYSTEMTIME structure:

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;


but how to get it running in realtime as it elapses seconds by seconds
like

8:56:01 AM Monday, December 02, 2008
...then
8:56:02 AM Monday, December 02, 2008
...then
8:56:03 AM Monday, December 02, 2008


Regards.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • DateiZeit
    ... bool CDlgExFiles::SetFileTime(CString fName, CTime cTime) ... FILETIME ft; ... SYSTEMTIME st; ... HANDLE hFind; ...
    (microsoft.public.de.vc)
  • Re: How do I put the date time into a DWORD?
    ... could assign it to a CTime and use CTimeSpan. ... COleDateTime: ... SYSTEMTIME st; ...
    (microsoft.public.vc.language)