Timer enabling problem

Hi,

I am facing one problem.

Scenario is like this
1. User enters some information which I want to process at time say 11.15 AM. User added this job at 11.00 AM
2. When it is 11:15 AM my program should start automatically and do the required operation.

The problem I am facing is like this
SetTimer function is used when I enter time at 11.00 AM. Then I will get one timer and time span between 11.00 AM to 11.15 AM is found in milliseconds
when that timer expires I am having a call back function that gets called.

The problem comes if user changes time by going into system tray manually it will not start at 11:15 AM. Instead it will start after the expiry of time only. How to solve this

thanks
regards
Raghavendra H
[791 byte] By [hraghavendra] at [2007-11-18 3:48:10]
# 1 Re: Timer enabling problem
Instead of relying on the timer firing after an elapsed timespan, you could use your timer function to get the current system time periodically (every second?) and check against the alarm time.
gstercken at 2007-11-11 3:39:43 >
# 2 Re: Timer enabling problem
Thanks very much.

Can you please provide me more details about how to go about.
How to have my owntimer which checks the system time every second?

thanks in advance
regards
Raghavendra H
hraghavendra at 2007-11-11 3:40:50 >
# 3 Re: Timer enabling problem
CWnd::OnTimeChange
afx_msg void OnTimeChange( );

Remarks

The framework calls this member function after the system time is changed.

Have any application that changes the system time send this message to all top-level windows. To send the WM_TIMECHANGE message to all top-level windows, an application can use theSendMessage Windows function with its hwnd parameter set to HWND_BROADCAST.
alex_gusev at 2007-11-11 3:41:49 >
# 4 Re: Timer enabling problem
Originally posted by alex_gusev
OnTimeChange()
OK, but this will still require killing the timer, calculating the new time span and creating a new timer. The following approach is far easier:const UINT MY_TIMER_ID = 42;
//...

SetTimer(MY_TIMER_ID, 1000, NULL); //Check every second
//...

void CMyWnd::OnTimer(UINT nIDEvent)
{
if(nIDEvent == MY_TIMER_ID)
{
CTime currentTime = CTime::GetCurrentTime();
if(currentTime >= m_scheduledTime)
{
// OK, time has come to perform task
}
}
CWnd::OnTimer(nIDEvent);
}
gstercken at 2007-11-11 3:42:50 >
# 5 Re: Timer enabling problem
Hi,

Thanks for earlier suggestion.
I am having too many things to be looked into when time to start operation expires.

I am looking for something like this.

If user manually updates the time from system tray or from dos prompt any message is sent out to Windows OS. If we trap this message it will be of more help ful.

please help me on this

thanks
regards
Raghavendra H
hraghavendra at 2007-11-11 3:43:56 >
# 6 Re: Timer enabling problem
hi hraghavendra,

as I've posted above, checl out CWnd::OnTimeChange method. it's sent anytime user changes system time
alex_gusev at 2007-11-11 3:44:55 >