stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Does CloseApplication kill main window?

I'd like to use 7.0's CloseApplication predefined action, but I"m not sure what it does.

The manual says it *basically* sends WM_CLOSE to all windows created by the app. What else does it do?

Normally you close an app by closing its main window. Does the custom action send WM_CLOSE to the exe's main window first? Does it then wait for that window to close before querying for more windows? Or Is there a way to limit the action to send WM_CLOSE to only the main window?

I don't like the idea of sending WM_CLOSE to windows in random order, since such actions may trigger app code, or worse, cause exceptions if certain windows are meant to always be alive while the app is running.

Also, does CloseApplication finally terminate the process in case the app does not close? My suggestion would be for it not to terminate the process, and leave it to the developer to add a TerminateProcess action afterwards as a catch-all, if desired.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Does CloseApplication kill main window?

Hi,
The manual says it *basically* sends WM_CLOSE to all windows created by the app. What else does it do?
The only output from this custom action is represented by the WM_CLOSE messages. The custom action doesn't do anything else to the application.
Does the custom action send WM_CLOSE to the exe's main window first?
Yes, the main windows receive the message first.
Does it then wait for that window to close before querying for more windows?
No, after sending the message to a window it continues to the next windows.
I don't like the idea of sending WM_CLOSE to windows in random order, since such actions may trigger app code, or worse, cause exceptions if certain windows are meant to always be alive while the app is running.
The custom action affects only windows which:
- have a caption
- have a system menu
- are overlapped or tiled

If this custom action may not work for your application, you can try creating another one using custom code. This way you can ensure maximum compatibility.
Also, does CloseApplication finally terminate the process in case the app does not close?
No, the process is not terminated.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Does CloseApplication kill main window?

What exactly do you mean by "are overlapped or tiled"?

I would suggest not excluding windows that lack a system menu. Not all app windows use one.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Does CloseApplication kill main window?

Hi,
What exactly do you mean by "are overlapped or tiled"?
The windows use the WS_OVERLAPPED or WS_TILED flags.
I would suggest not excluding windows that lack a system menu. Not all app windows use one.
We will consider adding this improvement in a future version. Thank you for your suggestion. Please note that the custom action targets the main window of an application, not all windows.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Does CloseApplication kill main window?

Thanks Cosmin,

I'm trying to confirm your last statement. Originally I understood that the standard action CloseApplication sends WM_CLOSE to all windows of a process. Are you saying that it in fact sends it to only the main window?

Fine with me if that's the case; I just want to confirm that's what you're saying.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Does CloseApplication kill main window?

Hi,
Originally I understood that the standard action CloseApplication sends WM_CLOSE to all windows of a process. Are you saying that it in fact sends it to only the main window?
The custom action affects only windows which:
- have a caption
- have a system menu
- are overlapped or tiled

This criteria is usually met only by the main window of an application.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Does CloseApplication kill main window?

http://msdn.microsoft.com/en-us/magazine/cc301495.aspx has a discussion of finding an app's main window. I might suggest iterating through windows using this method (instead of window style bits), starting with visible ones first. CloseApplication would then work with systray applications like mine.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Does CloseApplication kill main window?

Hi,

Using this method will not find application windows which are minimized to tray. Also, not using the WS_VISIBLE flag in order to check minimized windows would detect to many windows. However, a future version will allow you to set the flags which should be checked by the custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”