以下是我测试用的代码,就是想看看何种情况发生OnActivate事件。
(Form1是主窗体)procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  Form3.ShowModal;
end;procedure TForm1.FormActivate(Sender: TObject);
begin
  Memo1.Lines.Add('OnActivate ' + FormatDateTime('yyyy-mm-dd hh:mm:ss',Now()))
end;下面是delphi帮助中的说明
DescriptionUse OnActivate to perform special processing when the form receives focus. A form becomes active when focus is transferred to it (when the user clicks on the form, for example).Note: The OnActivate event of the application (TApplication), not the form, occurs when control switches  from another application.我记得很久以前试验时,只要form1一获得焦点,就触发OnActivate事件。但我用上面的代码测试却不是这样的。form3关闭的时候,虽然form1是active状态,但却没显示触发OnActivate事件,因为没看到memo1中增加记录。不打开form3,只打开form2,form2与form1间来回切换,可以看到form1触发了OnActivate事件。于是我很困惑,为什么用ShowModal方法打开的form3关闭后form1不触发OnActivate事件呢?OnActivate事件到底在什么情况下触发呢?
由于很久以前的试验的现象,所以我很少使用(几乎不使用)OnActivate事件。现在要给别人解释为什么不用的时候,出现了这样的困惑,还请大虾们指教。