• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision8762 (tree)
Time2020-05-02 22:25:04
Authorzmatsuo

Log Message

ExpandCBWidth() を dlglib に移動

Change Summary

Incremental Difference

--- trunk/teraterm/common/dlglib.h (revision 8761)
+++ trunk/teraterm/common/dlglib.h (revision 8762)
@@ -100,6 +100,7 @@
100100 int GetFontPixelFromPoint(HWND hWnd, int point);
101101 wchar_t *AllocControlTextW(HWND hWnd);
102102 char *AllocControlTextA(HWND hWnd);
103+void ExpandCBWidth(HWND dlg, int ID);
103104
104105 #ifdef __cplusplus
105106 }
--- trunk/teraterm/common/dlglib_cpp.cpp (revision 8761)
+++ trunk/teraterm/common/dlglib_cpp.cpp (revision 8762)
@@ -183,3 +183,32 @@
183183 ReleaseDC(hWnd, DC);
184184 return pixel;
185185 }
186+
187+/**
188+ * リストの横幅を拡張する(元の幅より狭くなることはない)
189+ * @param[in] dlg ダイアログのハンドル
190+ * @param[in] ID コンボボックスのID
191+ */
192+void ExpandCBWidth(HWND dlg, int ID)
193+{
194+ HWND hCtrlWnd = GetDlgItem(dlg, ID);
195+ int count = (int)SendMessage(hCtrlWnd, CB_GETCOUNT, 0, 0);
196+ HFONT hFont = (HFONT)SendMessage(hCtrlWnd, WM_GETFONT, 0, 0);
197+ int i, max_width = 0;
198+ HDC TmpDC = GetDC(hCtrlWnd);
199+ hFont = (HFONT)SelectObject(TmpDC, hFont);
200+ for (i=0; i<count; i++) {
201+ SIZE s;
202+ int len = (int)SendMessage(hCtrlWnd, CB_GETLBTEXTLEN, i, 0);
203+ char *lbl = (char *)calloc(len+1, sizeof(char));
204+ SendMessage(hCtrlWnd, CB_GETLBTEXT, i, (LPARAM)lbl);
205+ GetTextExtentPoint32(TmpDC, lbl, len, &s);
206+ if (s.cx > max_width)
207+ max_width = s.cx;
208+ free(lbl);
209+ }
210+ max_width += GetSystemMetrics(SM_CXVSCROLL); // スクロールバーの幅も足し込んでおく
211+ SendMessage(hCtrlWnd, CB_SETDROPPEDWIDTH, max_width, 0);
212+ SelectObject(TmpDC, hFont);
213+ ReleaseDC(hCtrlWnd, TmpDC);
214+}
--- trunk/ttssh2/ttxssh/ttxssh.c (revision 8761)
+++ trunk/ttssh2/ttxssh/ttxssh.c (revision 8762)
@@ -1290,35 +1290,6 @@
12901290 return CallWindowProc(OrigHostnameEditProc, dlg, msg, wParam, lParam);
12911291 }
12921292
1293-/**
1294- * リストの横幅を拡張する(元の幅より狭くなることはない)
1295- * @param[in] dlg ダイアログのハンドル
1296- * @param[in] ID コンボボックスのID
1297- */
1298-static void ExpandCBWidth(HWND dlg, int ID)
1299-{
1300- HWND hCtrlWnd = GetDlgItem(dlg, ID);
1301- int count = (int)SendMessage(hCtrlWnd, CB_GETCOUNT, 0, 0);
1302- HFONT hFont = (HFONT)SendMessage(hCtrlWnd, WM_GETFONT, 0, 0);
1303- int i, max_width = 0;
1304- HDC TmpDC = GetDC(hCtrlWnd);
1305- hFont = (HFONT)SelectObject(TmpDC, hFont);
1306- for (i=0; i<count; i++) {
1307- SIZE s;
1308- int len = (int)SendMessage(hCtrlWnd, CB_GETLBTEXTLEN, i, 0);
1309- char *lbl = (char *)calloc(len+1, sizeof(char));
1310- SendMessage(hCtrlWnd, CB_GETLBTEXT, i, (LPARAM)lbl);
1311- GetTextExtentPoint32(TmpDC, lbl, len, &s);
1312- if (s.cx > max_width)
1313- max_width = s.cx;
1314- free(lbl);
1315- }
1316- max_width += GetSystemMetrics(SM_CXVSCROLL); // スクロールバーの幅も足し込んでおく
1317- SendMessage(hCtrlWnd, CB_SETDROPPEDWIDTH, max_width, 0);
1318- SelectObject(TmpDC, hFont);
1319- ReleaseDC(hCtrlWnd, TmpDC);
1320-}
1321-
13221293 static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
13231294 LPARAM lParam)
13241295 {
Show on old repository browser