Wm_endsession


#1

My application is set up so that various settings are saved to a properties file when the app is shut down.

However, JUCE does not currently catch the WM_ENDSESSION message, so my application is not told that Windows is shutting down or restarting and the settings are not saved.

I found a workaround for this for the time being, but it seems that a good idea for the main JUCE window handler to catch this message and tell the application to quit.

Matt


#2

Ok, good call, I’ll see what I can do about that.


#3

This turns out to be trickier than I thought.

It looks like if you want to save data to disk, you need to do it right when you receive the end session message.

I originally had my message handler just telling the JUCE application to quit, which automatically writes to the properties file. Doing that didn’t work; doing this does:

[code]void ConsoleApp::Win32MessageReceived(UINT uMsg,WPARAM wParam,LPARAM lParam)
{
if (WM_ENDSESSION == uMsg)
{
const MessageManagerLock mmLock;
ConsoleWindow *window = _windowlist;

	for (int idx = 0; idx < _wincount; idx++)
	{
		window->SaveProps();
		window = window->_cwnext;
	}
}

}[/code]

using the stuff I posted earlier today in the “useful components” section.


#4