Application Deactivate() event not fired on quitting

Deactivate() does not fire when an application quits. I would have thought that this would be the order of the events:

  • Open
  • Activate
  • [ Deactivate Activate ] // happens when switching to other applications and then back
  • CancelClose
  • Deactivate // not called
  • Close

Is this a bug?

I’m pretty sure it’s not a bug. My guess would be that since the application doesn’t lose focus to another application when it quits, it simply quits, the deactivate event is never fired.

Didn’t think of that - makes sense.

Since I need the symmetry Open/Close and Activate/Deactivate I’m going to subclass Application and raise Deactivate before raising Close in the subclass’s Close event.

Please post here how that works for you. I would suspect that will result in some unanticipated behavior, but I’ve never tried it.

[quote=55592:@Eli Ott]Didn’t think of that - makes sense.

Since I need the symmetry Open/Close and Activate/Deactivate I’m going to subclass Application and raise Deactivate before raising Close in the subclass’s Close event.[/quote]

Just put all your code of the Activate and Deactivate events in methods and call them when you need it.

On Windows, even Window1.close doesn’t fire the deactivate event, while the activate event fires correctly.
(FB 1569 , 2008)

[quote=298497:@Joost Rongen]On Windows, even Window1.close doesn’t fire the deactivate event, while the activate event fires correctly.
(FB 1569 , 2008)[/quote]
do you have App.AutoQuit=true ?

I have. But the issue I mend was about opening and closing windows within the app. Deactivate just should fire as a result of Window.close according to my opinion, Activate does on Window.open.

sorry… didn’t realize you meant the Window deactivate, as opposed to the App

I disagree. The window is not deactivating, it is closing. Activate fires with Window.Open because the window is being called to the front, Activated. If there was a way to open a window behind the others and not bring it to the front, I would expect Open to fire but not Activate.

At any rate, CancelClose should fire.

Yes, it does. So not a big thing.

@Tim Parnell - after reading, think your are right.