From 30052dbd9ef8501393c9916aa20b7ee5bc1a2a13 Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 12 Mar 2015 19:47:44 -0300 Subject: [PATCH] Show internal Win32 error if we use GetOpenFileName Win32 API function incorrectly --- src/she/win/native_dialogs.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/she/win/native_dialogs.cpp b/src/she/win/native_dialogs.cpp index ea7949ab1..2fe973d33 100644 --- a/src/she/win/native_dialogs.cpp +++ b/src/she/win/native_dialogs.cpp @@ -11,6 +11,7 @@ #include "she/win/native_dialogs.h" #include "base/string.h" +#include "she/error.h" #include @@ -93,7 +94,22 @@ public: ofn.Flags |= OFN_OVERWRITEPROMPT; #endif - return GetOpenFileName(&ofn) != FALSE; + BOOL res; + if (m_save) + res = GetSaveFileName(&ofn); + else + res = GetOpenFileName(&ofn); + + if (!res) { + DWORD err = CommDlgExtendedError(); + if (err) { + std::vector buf(1024); + sprintf(&buf[0], "Error using GetOpen/SaveFileName Win32 API. Code: %d", err); + she::error_message(&buf[0]); + } + } + + return res != FALSE; } private: