1. Home
  2. Computing & Technology
  3. Delphi Programming

How to handle system time change

By , About.com Guide

If you need to react when system date time has changed you can handle the WM_TimeChange Windows message.
Here's a sample code:

~~~~~~~~~~~~~~~~~~~~~~~~~
type
   TForm1 = class(TForm)
   private
     procedure WMTimeChange(var Msg: TMessage) ; message WM_TIMECHANGE;
   end;

var
   Form1: TForm1;

implementation
{$R *.DFM}

procedure TForm1.WMTimeChange(var Msg: TMessage) ;
begin
   inherited;
   ShowMessage('Date/Time has changed!') ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Note: the "Handling Windows Messages the Delphi way" article has more info on Windows message handling from Delphi code.

Delphi tips navigator:
» Fixing the RadioButtonList ASP.NET Web Server control - adding Attributes to Items
« How to Split and Merge Files using Delphi code

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2005 Delphi Tips
  7. How to handle system time change using Delphi code

©2009 About.com, a part of The New York Times Company.

All rights reserved.