Gabor Boros wrote: > Every time when the form activated the > OnActivate event triggered, after switched to another app and switched > back etc. I try to eliminate this by write if Active then Exit; to the > OnActivate but in this case things after the if Activate... line never > triggered.
For Windows the OnActivate event should fire every time the window is re-activated as you describe. This is as designed. If you want to process something only once when the window is first activated try the OnShow event. If you must run some code only once but still within the OnActivate handler, the best way I have found is to add a field to the TForm that indicates the OnActivate has been run once. I usually use FActivated: Boolean for this. Then in the OnActivate handler put: if not FActivated then begin //Do some work here that should only happen once FActivated := True; end; _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
