Hello all, I am having a little bit of trouble making a program work.
What I am trying to write is a basic little applet to let the user set
the system time from a date/time picker control. I also intend for the
applet to display the current time when it is first opened.
Here is what I have: an MFC dialog based application. There is a main
dialog, with a date/time picker control, an OK button and a Cancel
button. The date time picker control is hooked to a CTime object
m_CurrentTime in the dialog class. The date/time picker is set to "time"
format, and is user editable. There is also a SYSTEMTIME object, st,
defined as a dialog class member.
The dialog constructor assigns the current time to m_CurrentTime as
follows:
m_CurrentTime = CTime::GetCurrentTime();
this part seems to work OK. When the applet starts, the current system
time is displayed in the date/timer picker.
Then, in the OnOK function, I do this, to supposedly set the system time
to the time in CurrentTime.
m_CurrentTime.GetAsSystemTime( st );
::SetSystemTime( &st );
This program is built using VC++ 6.0, SP3, on Windows 95. When I
execute it, and set a new time and click OK, the following happens:
The system clock seems to get updated, but it takes 5 to 10 seconds
after the program closes, before the taskbar clock shows the updated
time, which is inevitably something different from what I select in the
date/time picker. Also, after running this program, my system date is
now wrong.
Can anybody give me any clue on what exactly I am doing wrong? Thanks
in advance!
Phil
--
remove "REMOVE-NOSPAM" from my e-mail address to reply.