From 42a46e83faa08bc117a206e83319b6b2e0051c57 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Wed, 18 Sep 2013 16:49:32 -0400 Subject: [PATCH] Use system-agnostic return values for SaveFileYesNoCancel() This function was returning ID{YES,NO,CANCEL}, which are specific to Windows as return values for MessageBox(). These have been replaced with SAVE_{YES,NO,CANCEL}, which we define ourselves. --- solvespace.cpp | 8 ++++---- solvespace.h | 4 ++++ win32/w32main.cpp | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/solvespace.cpp b/solvespace.cpp index 7f9cb7d..bf644ed 100644 --- a/solvespace.cpp +++ b/solvespace.cpp @@ -343,16 +343,16 @@ bool SolveSpace::OkayToStartNewFile(void) { if(!unsaved) return true; switch(SaveFileYesNoCancel()) { - case IDYES: + case SAVE_YES: return GetFilenameAndSave(false); - case IDNO: + case SAVE_NO: return true; - case IDCANCEL: + case SAVE_CANCEL: return false; - default: oops(); + default: oops(); break; } } diff --git a/solvespace.h b/solvespace.h index ddb71db..ba0d856 100644 --- a/solvespace.h +++ b/solvespace.h @@ -82,7 +82,11 @@ class ExprQuaternion; extern char RecentFile[MAX_RECENT][MAX_PATH]; void RefreshRecentMenus(void); +#define SAVE_YES (1) +#define SAVE_NO (-1) +#define SAVE_CANCEL (0) int SaveFileYesNoCancel(void); + // SolveSpace native file format #define SLVS_PATTERN "SolveSpace Models (*.slvs)\0*.slvs\0All Files (*)\0*\0\0" #define SLVS_EXT "slvs" diff --git a/win32/w32main.cpp b/win32/w32main.cpp index 339e6a8..1846761 100644 --- a/win32/w32main.cpp +++ b/win32/w32main.cpp @@ -873,7 +873,14 @@ int SaveFileYesNoCancel(void) EnableWindow(GraphicsWnd, TRUE); SetForegroundWindow(GraphicsWnd); - return r; + switch(r) { + case IDYES: return SAVE_YES; + case IDNO: return SAVE_NO; + case IDCANCEL: return SAVE_CANCEL; + } + + oops(); + return SAVE_CANCEL; } void LoadAllFontFiles(void)