Ask to save before exit on Win32

Closes #65
This commit is contained in:
Daniel Collin 2013-07-01 11:53:06 +02:00
parent 4d13534798
commit 23f5a4912f

View File

@ -563,6 +563,22 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam
case WM_CLOSE:
{
int res;
if (!Editor_needsSave())
{
PostQuitMessage(0);
return 0;
}
res = MessageBox(window, L"Do you want to save the work?", L"Save before exit?", MB_YESNOCANCEL | MB_ICONQUESTION);
if (res == IDCANCEL)
return 0;
if (res == IDYES)
Editor_saveBeforeExit();
PostQuitMessage(0);
return 0;
}
@ -617,6 +633,8 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmndLine, i
done = true;
}
}
Sleep(1); // to prevent hammering the thread
}
saveRecentFileList();