[ttssh2-commit] [10745] コンボボックスドロップダウンリストの横幅設定をUnicode化した

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2023年 6月 8日 (木) 00:28:59 JST


Revision: 10745
          https://osdn.net/projects/ttssh2/scm/svn/commits/10745
Author:   zmatsuo
Date:     2023-06-08 00:28:59 +0900 (Thu, 08 Jun 2023)
Log Message:
-----------
コンボボックスドロップダウンリストの横幅設定をUnicode化した

- ExpandCBWidth()

Modified Paths:
--------------
    trunk/teraterm/common/dlglib_cpp.cpp

-------------- next part --------------
Modified: trunk/teraterm/common/dlglib_cpp.cpp
===================================================================
--- trunk/teraterm/common/dlglib_cpp.cpp	2023-06-07 15:28:47 UTC (rev 10744)
+++ trunk/teraterm/common/dlglib_cpp.cpp	2023-06-07 15:28:59 UTC (rev 10745)
@@ -209,30 +209,36 @@
 }
 
 /**
+ *	\x83R\x83\x93\x83{\x83{\x83b\x83N\x83X\x81A\x83h\x83\x8D\x83b\x83v\x83_\x83E\x83\x93\x83\x8A\x83X\x83g\x82\xCC
  *	\x83\x8A\x83X\x83g\x82̉\xA1\x95\x9D\x82\xF0\x8Ag\x92\xA3\x82\xB7\x82\xE9(\x8C\xB3\x82̕\x9D\x82\xE6\x82苷\x82\xAD\x82Ȃ邱\x82Ƃ͂Ȃ\xA2)
+ *	\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82镶\x8E\x9A\x82\xAA\x82\xB7\x82ׂČ\xA9\x82\xA6\x82\xE9\x82悤\x82ɂ\xB7\x82\xE9
+ *
  *	@param[in]	dlg		\x83_\x83C\x83A\x83\x8D\x83O\x82̃n\x83\x93\x83h\x83\x8B
  *	@param[in]	ID		\x83R\x83\x93\x83{\x83{\x83b\x83N\x83X\x82\xCCID
+ *
+ *	\x83R\x83\x93\x83{\x83{\x83b\x83N\x83X\x82Ƀe\x83L\x83X\x83g\x82\xF0\x83Z\x83b\x83g(SetDlgItemTextW(dlg, ID, L"text");)
+ *	\x82\xB7\x82\xE9\x91O\x82ɃR\x81[\x83\x8B\x82\xB7\x82\xE9\x82ƃt\x83H\x81[\x83J\x83X\x82\xAA\x82\xA8\x82\xA9\x82\xB5\x82\xAD\x82Ȃ邱\x82Ƃ\xAA\x82Ȃ\xA2
  */
 void ExpandCBWidth(HWND dlg, int ID)
 {
 	HWND hCtrlWnd = GetDlgItem(dlg, ID);
-	int count = (int)SendMessage(hCtrlWnd, CB_GETCOUNT, 0, 0);
-	HFONT hFont = (HFONT)SendMessage(hCtrlWnd, WM_GETFONT, 0, 0);
+	int count = (int)SendMessageW(hCtrlWnd, CB_GETCOUNT, 0, 0);
+	HFONT hFont = (HFONT)SendMessageW(hCtrlWnd, WM_GETFONT, 0, 0);
 	int i, max_width = 0;
 	HDC TmpDC = GetDC(hCtrlWnd);
 	hFont = (HFONT)SelectObject(TmpDC, hFont);
-	for (i=0; i<count; i++) {
+	for (i = 0; i < count; i++) {
 		SIZE s;
-		int len = (int)SendMessage(hCtrlWnd, CB_GETLBTEXTLEN, i, 0);
-		char *lbl = (char *)calloc(len+1, sizeof(char));
-		SendMessage(hCtrlWnd, CB_GETLBTEXT, i, (LPARAM)lbl);
-		GetTextExtentPoint32(TmpDC, lbl, len, &s);
+		int len = (int)SendMessageW(hCtrlWnd, CB_GETLBTEXTLEN, i, 0);
+		wchar_t *text = (wchar_t *)calloc(len + 1, sizeof(wchar_t));
+		SendMessageW(hCtrlWnd, CB_GETLBTEXT, i, (LPARAM)text);
+		GetTextExtentPoint32W(TmpDC, text, len, &s);
 		if (s.cx > max_width)
 			max_width = s.cx;
-		free(lbl);
+		free(text);
 	}
-	max_width += GetSystemMetrics(SM_CXVSCROLL);	// \x83X\x83N\x83\x8D\x81[\x83\x8B\x83o\x81[\x82̕\x9D\x82\xE0\x91\xAB\x82\xB5\x8D\x9E\x82\xF1\x82ł\xA8\x82\xAD
-	SendMessage(hCtrlWnd, CB_SETDROPPEDWIDTH, max_width, 0);
+	max_width += GetSystemMetrics(SM_CXVSCROLL);  // \x83X\x83N\x83\x8D\x81[\x83\x8B\x83o\x81[\x82̕\x9D\x82\xE0\x91\xAB\x82\xB5\x8D\x9E\x82\xF1\x82ł\xA8\x82\xAD
+	SendMessageW(hCtrlWnd, CB_SETDROPPEDWIDTH, max_width, 0);
 	SelectObject(TmpDC, hFont);
 	ReleaseDC(hCtrlWnd, TmpDC);
 }


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