I am trying to reply to windows and application messages, but I get them several times.
For example, I write the following code to display a message box when the system date is changed using WM_TIMECHANGE. WMTimeChange is executed more than once, and I see one-time (most often two or three) mailboxes one after another. Maybe I missed something?
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) protected procedure WMTimeChange(var Msg: TMessage) ; message WM_TIMECHANGE; end; var Form1: TForm1; implementation {$R *.dfm} { TForm1 } procedure TForm1.WMTimeChange(var Msg: TMessage); begin showmessage('Date/Time has changed!'); end; end.
Testing in Windows XP.
EDIT: just to clarify, my intention is to understand WHY , and not how to get around a few challenges. In any case, if the answer to this question is not possible, I will probably accept one answer later.
EDIT2: Delphi tag removed because it is not a Delphi problem.
source share