In normal case OnActivate of a Form is called only one time after showing a Form with ShowModal.
I've used for the same circumstance (though not due to TMS) a private form variable (boolean) which is initialised in FormCreate; in FormActivate it's checked if already true and if so just exit; otherwise set it to true and continue.
With that it (almost) does not matter whether one uses the FormActivate or FormShow event.
Could you please provide more information about what components you use & how exactly to reproduce the issue.
When we have more detailed information, we'll be able to provide much better & well informed guidelines / solutions.
To reproduce multiple FormActivate:
- new project
- drop a TAdvSmoothDatePicker at the form (our current version is 1.5.4.2)
- create the FormActivate event
- open calender using arrow button
- click at a date
After closing the calender the FormActivate is fired again !
complete unit
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, AdvSmoothEdit, AdvSmoothEditButton, AdvSmoothDatePicker;
type
TForm1 = class(TForm)
AdvSmoothDatePicker1: TAdvSmoothDatePicker;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
MessageBox(0, 'FormActivate', '', 0);
end;
end.
Thanks
Frank
It is a known behavior that the form will be activated again when the datepicker dropdown is hidden. The dropdown becomes the active window as it starts to receive the keyboard focus. When the dropdown closes, the active window changes, hence the parent form's OnActivate is triggered.
Hm, using the standard TDateTimePicker does not fires the FormActivate after closing ...
What is the difference ?
Thanks
Frank
The difference lies in the fact that the keyboard events are set directly on the Calendar. Which needs the focus to operate correctly.
OK, makes sense,
but on TDateTimePicker I also can use the keyboard (eg arrow keys).
Thanks
Frank