summaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp85
1 files changed, 73 insertions, 12 deletions
diff --git a/src/common.cpp b/src/common.cpp
index ced7779..2c9d01f 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -18,6 +18,7 @@
//
// -------------------------------------------------------------------------
//
+#include <cstring>
#include "w32dlib/common.h"
namespace W32DLib
@@ -49,25 +50,85 @@ bool Common::Query(HWND parent, const char *msg)
// ------------------------------------------------------------
//
-std::string OpenFile(const char *filter)
+bool Common::OpenFile(HWND parent,
+ const char *title,
+ std::string& path,
+ const char *filter)
{
- return std::string();
+ char buff[1024];
+ OPENFILENAME ofn={sizeof(OPENFILENAME),0};
+
+ if (path.length())
+ {
+ std::strcpy(buff,path.c_str());
+ }
+ else
+ {
+ buff[0]=0;
+ }
+
+ ofn.hwndOwner=parent;
+ ofn.lpstrFilter=filter;
+ ofn.lpstrCustomFilter=NULL;
+ ofn.nFilterIndex=1;
+ ofn.lpstrFile=buff;
+ ofn.nMaxFile=sizeof buff;
+ ofn.lpstrFileTitle=NULL;
+ ofn.lpstrInitialDir=NULL;
+ ofn.lpstrTitle=title;
+ ofn.Flags=OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
+
+ if (GetOpenFileName(&ofn))
+ {
+ path=buff;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
// ------------------------------------------------------------
//
-std::string SaveFile(const char *filter)
+bool Common::SaveFile(HWND parent,
+ const char *title,
+ std::string& path,
+ const char *filter)
{
- return std::string();
-}
-
-
-// ------------------------------------------------------------
-//
-std::string SelectDirectory()
-{
- return std::string();
+ char buff[1024];
+ OPENFILENAME ofn={sizeof(OPENFILENAME),0};
+
+ if (path.length())
+ {
+ std::strcpy(buff,path.c_str());
+ }
+ else
+ {
+ buff[0]=0;
+ }
+
+ ofn.hwndOwner=parent;
+ ofn.lpstrFilter=filter;
+ ofn.lpstrCustomFilter=NULL;
+ ofn.nFilterIndex=1;
+ ofn.lpstrFile=buff;
+ ofn.nMaxFile=sizeof buff;
+ ofn.lpstrFileTitle=NULL;
+ ofn.lpstrInitialDir=NULL;
+ ofn.lpstrTitle=title;
+ ofn.Flags=0;
+
+ if (GetSaveFileName(&ofn))
+ {
+ path=buff;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}