title: How to be notified for time changes in Windows Service
body: <p>I created a WindowProc to be notified for system time changes:</p>
  
  <pre><code>constructor TJJWScheduler.Create;
  begin 
    fTimeChangeWnd := Classes.AllocateHWnd(TimeChangeWndProc);
  end;
  
  procedure TJJWScheduler.TimeChangeWndProc(var msg: TMessage);
  var
    i: integer;
  begin
    case msg.Msg of
      WM_TIMECHANGE:
        begin
          // my things
        end;
    end;
  end;
  </code></pre>
  
  <p>This code is running inside a Windows Service.
  The problem is that it isn't fired when I change the system time!</p>
  
  <p>Why not the broadcast message (WM_TIMECHANGE) isn't delivered to my window?
  There is another way to do this without a loop?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I don't known why, but I hardcoded the PeekMessage to process messages to that window, and everything comes to work fine. The code below solved my problem:</p>
  
  <pre><code> var 
     msg: TMsg;
  
   if PeekMessage(msg, fTimeChangeWnd, WM_TIMECHANGE, WM_TIMECHANGE, PM_REMOVE) then
   begin
     TranslateMessage(msg);
     DispatchMessage(msg);
   end;
  </code></pre>
  
  <p>This workaround is very strange, because I already have others windows processing messages (by generic ProcessMessages), only this one isn't processing its messages.</p>