summaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-03-25 02:25:10 +0000
committerIan C <ianc@noddybox.co.uk>2005-03-25 02:25:10 +0000
commitbf252f63d520be07a938076518aa17c25b11f8be (patch)
tree0118bd10342317d265d72ba94ce13723fa7fd70a /src/common.cpp
parent72f0c86eb3ecdda4cab53213302fad645bc571f0 (diff)
Implemented OpenFile and SaveFile. Removed SelectDirectory as it depends on IE controls and COM
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;
+ }
}