Win2k doesn't send WM_TIMECHANGE on daylight savings event

D

Daniel Anderson

I seem to have a problem under win2k. Applications relying
on the WM_TIMECHANGE message to do recalculations when the
local time changes will fail. If the clock is changed
either manually or through synchronization via our LAN, the
message is received loud and clear. But at 2AM on a day
going into or out of daylight savings time, there is no
message sent by the os. My bios does not have the ability
to adjust for daylight savings time, so there is no
interference there. Under XP, applications receive this
message as expected. Anyone else find this? My
understanding is that Pre-NT5 os requires all apps to send
this message to all top level windows when they changed the
system time, and NT5+ handles WM_TIMECHANGE on its own with
no application to send. It seems as though the W2K codeset
responsible for the DST changeover does not comply with the
design.

Platform: Windows 2000 SP3, SP4
Timezone: GMT -3:00 Greenland
Times: (Scenario 1) April 4, 2004, 1:59 AM
(Scenario 2) October 31, 2004, 1:59 AM
Application: A simple C++ MFC SDI application, handling
WM_TIMECHANGE. Also tested with C application running as a
service but registered as a windows class, handling
WM_TIMECHANGE.

In Scenario 1, the time and date is set to the specified.
At 2:00AM, the clock display jumps to 3:00AM, as expected.
No WM_TIMECHANGE message is recieved by the application
under W2K, however it does with XP.

In Scenario 2, the time and date is set to the specified.
At 2:00AM the clock display jumps back to 1:00AM, as
expected. No WM_TIMECHANGE message is recieved by the
application under W2K, however it does with XP.


Cheers,
Dan
 
D

Daniel Anderson

According to the following MSDN article, Windows 2000 and
XP should behave the same way. But during a daylight
savings change, XP sends WM_TIMECHANGE to applications, but
2000 does not. Why? Where is this documented?

----------------------
WM_TIMECHANGE
An application sends the WM_TIMECHANGE message whenever it
updates the system time.

To send this message to all top-level windows, an
application can use the SendMessage function with the hWnd
parameter set to HWND_TOPMOST.

Windows 2000/XP: An application should not broadcast this
message, because the system will broadcast this message
when the application changes the system time.

Windows NT 4.0 and earlier: An application should send this
message to all top-level windows after changing the system
time.

Windows 95/98/Me: An application should send this message
to all top-level windows after changing the system time.

----------------------
 
J

John Phillips

I've seen the same behaviour Daniel, at least on the Win2k side. I'll try
with my WinXP machine when I get home tonight.

My first thought was that because the documentation for WM_TIMECHANGE says
that it is broadcast when the -=system time=- changes (which is always in
GMT), that it would make sense that it would -=not=- be broadcast when
entering or leaving DST (wouldn't explain the XP issue, but still...). But
when I change the time zone on my Win2k system, a WM_TIMECHANGE message is
fired.

As a workaround, you could:
- check the local time every few seconds or so (yuck)
- change your calculations to be based on GMT
- watch the
HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias
value by using RegNotifyChangeKeyValue() (this value changes when there is a
DST transition as well as when the time zone changes).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top