[Ttssh2-commit] [8688] _GetSaveFileNameW() を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2020年 4月 12日 (日) 00:53:56 JST


Revision: 8688
          https://osdn.net/projects/ttssh2/scm/svn/commits/8688
Author:   zmatsuo
Date:     2020-04-12 00:53:56 +0900 (Sun, 12 Apr 2020)
Log Message:
-----------
_GetSaveFileNameW() を追加

Modified Paths:
--------------
    trunk/teraterm/common/compat_win.cpp
    trunk/teraterm/common/compat_win.h
    trunk/teraterm/common/layer_for_unicode.h
    trunk/teraterm/common/layer_for_unicode_comctl32.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/compat_win.cpp
===================================================================
--- trunk/teraterm/common/compat_win.cpp	2020-04-11 15:53:47 UTC (rev 8687)
+++ trunk/teraterm/common/compat_win.cpp	2020-04-11 15:53:56 UTC (rev 8688)
@@ -106,7 +106,8 @@
 INT_PTR (WINAPI *pPropertySheetW)(LPCPROPSHEETHEADERW constPropSheetHeaderPointer);
 
 // comdlg32
-BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW Arg1);
+BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW ofnW);
+BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW ofnW);
 
 /**
  *	GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9
@@ -245,6 +246,7 @@
 static const APIInfo Lists_comdlg32[] = {
 #ifndef UNICODE_API_DISABLE
 	{ "GetOpenFileNameW", (void **)&pGetOpenFileNameW },
+	{ "GetSaveFileNameW", (void **)&pGetSaveFileNameW },
 #endif
 	{},
 };

Modified: trunk/teraterm/common/compat_win.h
===================================================================
--- trunk/teraterm/common/compat_win.h	2020-04-11 15:53:47 UTC (rev 8687)
+++ trunk/teraterm/common/compat_win.h	2020-04-11 15:53:56 UTC (rev 8688)
@@ -123,7 +123,8 @@
 extern void (WINAPI *pOutputDebugStringW)(LPCWSTR lpOutputString);
 extern DWORD (WINAPI *pGetCurrentDirectoryW)(DWORD nBufferLength, LPWSTR lpBuffer);
 extern BOOL (WINAPI *pSetCurrentDirectoryW)(LPCWSTR lpPathName);
-extern BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW Arg1);
+extern BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW ofnW);
+extern BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW ofnW);
 
 void WinCompatInit();
 

Modified: trunk/teraterm/common/layer_for_unicode.h
===================================================================
--- trunk/teraterm/common/layer_for_unicode.h	2020-04-11 15:53:47 UTC (rev 8687)
+++ trunk/teraterm/common/layer_for_unicode.h	2020-04-11 15:53:56 UTC (rev 8688)
@@ -129,7 +129,8 @@
 //INT_PTR _PropertySheetW(PROPSHEETHEADERW_V1 *constPropSheetHeaderPointer);
 
 // Comdlg32.lib
-BOOL _GetOpenFileNameW(LPOPENFILENAMEW Arg1);
+BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW);
+BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW);
 
 // shell32.lib
 UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);

Modified: trunk/teraterm/common/layer_for_unicode_comctl32.cpp
===================================================================
--- trunk/teraterm/common/layer_for_unicode_comctl32.cpp	2020-04-11 15:53:47 UTC (rev 8687)
+++ trunk/teraterm/common/layer_for_unicode_comctl32.cpp	2020-04-11 15:53:56 UTC (rev 8688)
@@ -114,12 +114,8 @@
 	return filterA;
 }
 
-BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW)
+static BOOL GetOpenSaveFileNameA(BOOL (WINAPI *fn)(LPOPENFILENAMEA ofnA), LPOPENFILENAMEW ofnW)
 {
-	if (pGetOpenFileNameW != NULL) {
-		return pGetOpenFileNameW(ofnW);
-	}
-
 	char fileA[MAX_PATH];
 	WideCharToMultiByte(CP_ACP, 0, ofnW->lpstrFile, -1, fileA, _countof(fileA), NULL,NULL);
 
@@ -131,8 +127,8 @@
 	ofnA.lpstrFile = fileA;
 	ofnA.nMaxFile = _countof(fileA);
 	ofnA.lpstrTitle = ToCharW(ofnW->lpstrTitle);
-	ofnA.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
-	BOOL result = GetOpenFileNameA(&ofnA);
+	ofnA.Flags = ofnW->Flags;
+	BOOL result = fn(&ofnA);
 	if (result) {
 		MultiByteToWideChar(CP_ACP, 0, fileA, _countof(fileA), ofnW->lpstrFile, ofnW->nMaxFile);
 	}
@@ -140,3 +136,21 @@
 	free((void *)ofnA.lpstrTitle);
 	return result;
 }
+
+BOOL _GetOpenFileNameW(LPOPENFILENAMEW ofnW)
+{
+	if (pGetOpenFileNameW != NULL) {
+		return pGetOpenFileNameW(ofnW);
+	}
+
+	return GetOpenSaveFileNameA(GetOpenFileNameA, ofnW);
+}
+
+BOOL _GetSaveFileNameW(LPOPENFILENAMEW ofnW)
+{
+	if (pGetSaveFileNameW != NULL) {
+		return pGetSaveFileNameW(ofnW);
+	}
+
+	return GetOpenSaveFileNameA(GetSaveFileNameA, ofnW);
+}


Ttssh2-commit メーリングリストの案内
Back to archive index