[ttssh2-commit] [9374] hGetDlgItemTextW() 追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 8月 19日 (木) 00:45:52 JST


Revision: 9374
          https://osdn.net/projects/ttssh2/scm/svn/commits/9374
Author:   zmatsuo
Date:     2021-08-19 00:45:52 +0900 (Thu, 19 Aug 2021)
Log Message:
-----------
hGetDlgItemTextW() 追加

Modified Paths:
--------------
    trunk/teraterm/common/win32helper.cpp
    trunk/teraterm/common/win32helper.h
    trunk/teraterm/teraterm/clipboarddlg.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/win32helper.cpp
===================================================================
--- trunk/teraterm/common/win32helper.cpp	2021-08-18 15:45:39 UTC (rev 9373)
+++ trunk/teraterm/common/win32helper.cpp	2021-08-18 15:45:52 UTC (rev 9374)
@@ -218,3 +218,9 @@
 	*text = strW;
 	return 0;
 }
+
+DWORD hGetDlgItemTextW(HWND hDlg, int id, wchar_t **text)
+{
+	HWND hWnd = GetDlgItem(hDlg, id);
+	return hGetWindowTextW(hWnd, text);
+}

Modified: trunk/teraterm/common/win32helper.h
===================================================================
--- trunk/teraterm/common/win32helper.h	2021-08-18 15:45:39 UTC (rev 9373)
+++ trunk/teraterm/common/win32helper.h	2021-08-18 15:45:52 UTC (rev 9374)
@@ -39,6 +39,7 @@
 DWORD hGetFullPathNameW(const wchar_t *lpFileName, wchar_t **fullpath, wchar_t **filepart);
 DWORD hGetCurrentDirectoryW(wchar_t **dir);
 DWORD hGetWindowTextW(HWND hWnd, wchar_t **text);
+DWORD hGetDlgItemTextW(HWND hDlg, int id, wchar_t **text);
 
 #ifdef __cplusplus
 }

Modified: trunk/teraterm/teraterm/clipboarddlg.cpp
===================================================================
--- trunk/teraterm/teraterm/clipboarddlg.cpp	2021-08-18 15:45:39 UTC (rev 9373)
+++ trunk/teraterm/teraterm/clipboarddlg.cpp	2021-08-18 15:45:52 UTC (rev 9374)
@@ -42,9 +42,11 @@
 #include "ttlib.h"
 #include "dlglib.h"
 #include "tt_res.h"
-#include "clipboarddlg.h"
 #include "compat_win.h"
+#include "win32helper.h"
 
+#include "clipboarddlg.h"
+
 static void GetDesktopRectFromPoint(POINT p, RECT *rect)
 {
 	if (pMonitorFromPoint == NULL) {
@@ -183,15 +185,12 @@
 				{
 					INT_PTR result = IDCANCEL;
 
-					size_t len = SendDlgItemMessageW(hDlgWnd, IDC_EDIT, WM_GETTEXTLENGTH, 0, 0);
-					len++; // for '\0'
-					wchar_t *strW = (wchar_t *)malloc(sizeof(wchar_t) * len);
-					if (strW != NULL) {
-						GetDlgItemTextW(hDlgWnd, IDC_EDIT, strW, (int)len);
-						strW[len - 1] = '\0';
+					wchar_t *strW;
+					DWORD error = hGetDlgItemTextW(hDlgWnd, IDC_EDIT, &strW);
+					if (error == NO_ERROR) {
+						data->strW_edited_ptr = strW;
 						result = IDOK;
 					}
-					data->strW_edited_ptr = strW;
 
 					DestroyWindow(hStatus);
 					TTEndDialog(hDlgWnd, result);


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