[Ttssh2-commit] [8268] ツールチップクラス化ブランチをマージした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 10月 7日 (月) 22:14:36 JST


Revision: 8268
          https://osdn.net/projects/ttssh2/scm/svn/commits/8268
Author:   yasuhide
Date:     2019-10-07 22:14:35 +0900 (Mon, 07 Oct 2019)
Log Message:
-----------
ツールチップクラス化ブランチをマージした

r8164 | auto_destroyを削除した
r8165 | TipWinの作成・削除の処理を統一した
r8166 | FRAME_WIDTHをTIP_WIN_FRAME_WIDTHに変更した
r8167 | _snprintf_sの引数を修正した
r8168 | TipWinの作成・削除の処理を明確にして整理した
r8169 | デバッグ用ヘッダを追加した
r8196 | [Tooltip] 初期化漏れを修正した
r8197 | [Tooltip] 不要な定義を整理した
r8198 | [Tooltip] RegisterClassの呼び出しをTera Term全体で1回にした
r8199 | [Tooltip] TipWinオブジェクトを破棄したあとで空にした
r8201 | [Tooltip] ウィンドウクラスを登録するときのチェックを強化した
r8202 | [Tooltip] タイマーの終了条件を修正した
r8203 | [Tooltip] ウィンドウクラス名をTeraTermTipWinClassに変更した
r8227 | [Tooltip] WNDCLASSをTipWinを使うファイル名から生成する
r8228 | [Tooltip] hInstanceを呼出側から渡せるようにした
r8229 | [Tooltip] TipWinの初期化処理を整理した
r8235 | [Tooltip] コンストラクタとCreate()の引数を変更した
r8255 | [Tooltip] 未使用変数の定義を削除した

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/8164
    https://osdn.net/projects/ttssh2/scm/svn/commits/8165
    https://osdn.net/projects/ttssh2/scm/svn/commits/8166
    https://osdn.net/projects/ttssh2/scm/svn/commits/8167
    https://osdn.net/projects/ttssh2/scm/svn/commits/8168
    https://osdn.net/projects/ttssh2/scm/svn/commits/8169
    https://osdn.net/projects/ttssh2/scm/svn/commits/8196
    https://osdn.net/projects/ttssh2/scm/svn/commits/8197
    https://osdn.net/projects/ttssh2/scm/svn/commits/8198
    https://osdn.net/projects/ttssh2/scm/svn/commits/8199
    https://osdn.net/projects/ttssh2/scm/svn/commits/8201
    https://osdn.net/projects/ttssh2/scm/svn/commits/8202
    https://osdn.net/projects/ttssh2/scm/svn/commits/8203
    https://osdn.net/projects/ttssh2/scm/svn/commits/8227
    https://osdn.net/projects/ttssh2/scm/svn/commits/8228
    https://osdn.net/projects/ttssh2/scm/svn/commits/8229
    https://osdn.net/projects/ttssh2/scm/svn/commits/8235
    https://osdn.net/projects/ttssh2/scm/svn/commits/8255

Modified Paths:
--------------
    trunk/teraterm/common/tipwin.cpp
    trunk/teraterm/common/tipwin.h
    trunk/teraterm/teraterm/addsetting.cpp
    trunk/teraterm/teraterm/sizetip.c
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/teraterm/teraterm/vtwin.h
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/ttssh2/ttxssh/auth.c

-------------- next part --------------
Modified: trunk/teraterm/common/tipwin.cpp
===================================================================
--- trunk/teraterm/common/tipwin.cpp	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/common/tipwin.cpp	2019-10-07 13:14:35 UTC (rev 8268)
@@ -59,24 +59,20 @@
 #include <stdio.h>
 #include <tchar.h>
 #include <assert.h>
+#if !defined(_CRTDBG_MAP_ALLOC)
+#define _CRTDBG_MAP_ALLOC
+#endif
+#include <crtdbg.h>
 
 #include "ttlib.h"		// for GetMessageboxFont()
 
 #include "tipwin.h"
 
-#ifdef _WIN64
-        typedef LONG_PTR WINDOW_LONG_PTR;
-#else
-        typedef LONG WINDOW_LONG_PTR;
-#endif
-
 typedef struct tagTipWinData {
 	HFONT tip_font;
 	COLORREF tip_bg;
 	COLORREF tip_text;
 	HWND tip_wnd;
-	HWND hParentWnd;
-	int tip_enabled;
 	const TCHAR *str;
 	size_t str_len;
 	RECT str_rect;
@@ -83,7 +79,7 @@
 	RECT rect;
 	int px;
 	int py;
-	BOOL auto_destroy;
+	TCHAR class_name[32];
 } TipWin;
 
 VOID CTipWin::CalcStrRect(VOID)
@@ -115,7 +111,7 @@
 			return TRUE;
 
 		case WM_PAINT:
-			{
+			if(self) {
 				HBRUSH hbr;
 				HGDIOBJ holdbr;
 				RECT cr;
@@ -138,10 +134,10 @@
 
 				{
 					RECT rect = self->tWin->str_rect;
-					rect.left = rect.left + FRAME_WIDTH;
-					rect.right = rect.right + FRAME_WIDTH;
-					rect.top = rect.top + FRAME_WIDTH;
-					rect.bottom = rect.bottom + FRAME_WIDTH;
+					rect.left = rect.left + TIP_WIN_FRAME_WIDTH;
+					rect.right = rect.right + TIP_WIN_FRAME_WIDTH;
+					rect.top = rect.top + TIP_WIN_FRAME_WIDTH;
+					rect.bottom = rect.bottom + TIP_WIN_FRAME_WIDTH;
 					DrawText(hdc, self->tWin->str, self->tWin->str_len, &rect, DT_LEFT);
 				}
 
@@ -154,16 +150,8 @@
 
 		case WM_NCHITTEST:
 			return HTTRANSPARENT;
-
-		case WM_DESTROY:
-			if(self->IsExists()) {
-				DeleteObject(self->tWin->tip_font);
-				self->tWin->tip_font = NULL;
-			}
-			break;
-
 		case WM_SETTEXT:
-			{
+			if(self) {
 				LPCTSTR str = (LPCTSTR) lParam;
 				const int str_width = self->tWin->str_rect.right - self->tWin->str_rect.left;
 				const int str_height = self->tWin->str_rect.bottom - self->tWin->str_rect.top;
@@ -175,19 +163,12 @@
 
 				SetWindowPos(hWnd, NULL,
 							 0, 0,
-							 str_width + FRAME_WIDTH * 2, str_height + FRAME_WIDTH * 2,
+							 str_width + TIP_WIN_FRAME_WIDTH * 2, str_height + TIP_WIN_FRAME_WIDTH * 2,
 				             SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
 				InvalidateRect(hWnd, NULL, FALSE);
-
 			}
 			break;
-
 		case WM_NCDESTROY:
-			if (self->IsExists() && self->tWin->auto_destroy) {
-				free((void *)self->tWin->str);
-				free(self->tWin);
-				self->tWin = NULL;
-				delete self;
 				/*
 				 * use-after-free\x82ɂ\xE6\x82\xE8Tera Term\x82̓\xAE\x8D삪\x95s\x88\xC0\x92\xE8\x82ƂȂ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B
 				 *
@@ -195,12 +176,14 @@
 				 * TipWin\x83\x81\x83\x93\x83o\x81[\x82\xF0\x81A\x82\xB1\x82\xB1\x82̃^\x83C\x83~\x83\x93\x83O\x82ʼn\xF0\x95\xFA\x82\xB5\x82Ă\xA2\x82\xBD\x82\xBD\x82߁B
 				 * \x90\xB3\x82\xB5\x82\xAD\x82\xCD CVTWindow \x83N\x83\x89\x83X\x82̃f\x83X\x83g\x83\x89\x83N\x83^\x82ʼn\xF0\x95\xFA\x82\xB7\x82\xE9\x81B
 				 */
-			}
 			break;
 		case WM_TIMER:
-			KillTimer(hWnd, self->timerid);
-			self->timerid = NULL;
-			self->SetVisible(FALSE);
+			if(self) {
+				if(self->timerid > 0)
+					KillTimer(hWnd, self->timerid);
+				self->timerid = 0;
+				self->SetVisible(FALSE);
+			}
 			break;
 		default:
 			break;
@@ -209,53 +192,76 @@
 	return DefWindowProc(hWnd, nMsg, wParam, lParam);
 }
 
-CTipWin::CTipWin(HWND src)
+CTipWin::CTipWin(HINSTANCE hInstance): hInstance(hInstance)
 {
-	Create(src, 0, 0, "");
-	SetVisible(FALSE);
+	tWin = (TipWin *)malloc(sizeof(TipWin));
+	memset(tWin, 0, sizeof(TipWin));
+	*class_name = NULL;
 }
 
-CTipWin::CTipWin(HWND src, int cx, int cy, const TCHAR *str)
+CTipWin::~CTipWin()
 {
-	Create(src, cx, cy, str);
-	SetVisible(TRUE);
+	if(IsExists()) {
+		Destroy();
+	}
+	if(tWin != NULL) {
+		free((void*)tWin->str);
+		tWin->str = NULL;
+		free(tWin);
+		tWin = NULL;
+		*class_name = NULL;
+	}
 }
 
-CTipWin::~CTipWin()
+BOOL CTipWin::IsClassRegistered()
 {
-	Destroy();
+	if (*class_name == NULL) {
+		_snprintf_s(class_name, sizeof(class_name), _TRUNCATE, _T("%s_%x"), TipWinClassName, hInstance);
+	}
+	WNDCLASS twc = { 0 };
+	return (GetClassInfo(hInstance, (LPCSTR)class_name, &twc) > 0);
 }
 
-ATOM CTipWin::tip_class;
+ATOM CTipWin::RegisterClass()
+{
+	WNDCLASS wc;
+	wc.style = CS_HREDRAW | CS_VREDRAW;
+	wc.lpfnWndProc = WndProc;
+	wc.cbClsExtra = 0;
+	wc.cbWndExtra = 0;
+	wc.hInstance = hInstance;
+	wc.hIcon = NULL;
+	wc.hCursor = NULL;
+	wc.hbrBackground = NULL;
+	wc.lpszMenuName = NULL;
+	wc.lpszClassName = (LPCSTR)class_name;
+	return ::RegisterClass(&wc);
+}
 
-VOID CTipWin::Create(HWND src, int cx, int cy, const TCHAR *str)
+BOOL CTipWin::UnregisterClass()
 {
-	const HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(src, GWLP_HINSTANCE);
+	return ::UnregisterClass((LPCSTR)class_name, hInstance);
+}
+
+VOID CTipWin::Create(HWND pHwnd)
+{
 	LOGFONTA logfont;
-	const UINT uDpi = GetMonitorDpiFromWindow(src);
+	const UINT uDpi = GetMonitorDpiFromWindow(pHwnd);
 
-	if (!tip_class) {
-		WNDCLASS wc;
-		wc.style = CS_HREDRAW | CS_VREDRAW;
-		wc.lpfnWndProc = WndProc;
-		wc.cbClsExtra = 0;
-		wc.cbWndExtra = 0;
-		wc.hInstance = hInst;
-		wc.hIcon = NULL;
-		wc.hCursor = NULL;
-		wc.hbrBackground = NULL;
-		wc.lpszMenuName = NULL;
-		wc.lpszClassName = _T("TipWinClass");
-
-		tip_class = RegisterClass(&wc);
+	if(hInstance == NULL) {
+		hInstance = (HINSTANCE)GetWindowLongPtr(pHwnd, GWLP_HINSTANCE);
 	}
-
-	tWin = (TipWin *)malloc(sizeof(TipWin));
-	if (tWin == NULL) return;
-	tWin->str_len = _tcslen(str);
-	tWin->str = _tcsdup(str);
-	tWin->px = cx;
-	tWin->py = cy;
+	if (! IsClassRegistered()) {
+		RegisterClass();
+	}
+	if (tWin == NULL) {
+		return;
+	}
+	tWin->str_len = 0;
+	tWin->str = (TCHAR*)malloc(sizeof(TCHAR));
+	memset((void*)tWin->str, 0, sizeof(TCHAR));
+	tWin->px = 0;
+	tWin->py = 0;
 	tWin->tip_bg = GetSysColor(COLOR_INFOBK);
 	tWin->tip_text = GetSysColor(COLOR_INFOTEXT);
 	GetMessageboxFont(&logfont);
@@ -262,11 +268,7 @@
 	logfont.lfWidth = MulDiv(logfont.lfWidth, uDpi, 96);
 	logfont.lfHeight = MulDiv(logfont.lfHeight, uDpi, 96);
 	tWin->tip_font = CreateFontIndirect(&logfont);
-	CalcStrRect();
 
-	const int str_width = tWin->str_rect.right - tWin->str_rect.left;
-	const int str_height = tWin->str_rect.bottom - tWin->str_rect.top;
-
 	/*
 	 * RegisterClass()\x82\xAA\x8E\xB8\x94s\x82\xB5\x82\xBD\x8Fꍇ\x82́ACreateWindowEx()\x82\xAA 87 (ERROR_INVALID_PARAMETER)\x82\xC5
 	 * \x83G\x83\x89\x81[\x82ƂȂ邽\x82߁A\x8CĂяo\x82\xB3\x82Ȃ\xA2\x82悤\x82ɂ\xB7\x82\xE9\x81B
@@ -274,32 +276,34 @@
 	 * WindowsMe(9x)\x82ł́ASSH\x94F\x8F؃_\x83C\x83A\x83\x8D\x83O\x82̃c\x81[\x83\x8B\x83`\x83b\x83v\x95\\x8E\xA6\x82\xC5 RegisterClass() \x82\xAA
 	 * \x8E\xB8\x94s\x82\xB7\x82\xE9\x81B\x8C\xB4\x88\xF6\x95s\x96\xBE\x81B
 	 */
-	tWin->tip_wnd = NULL;
-	if (tip_class) {
-		tWin->tip_wnd =
-			CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
-						   MAKEINTRESOURCE(tip_class),
-						   str, WS_POPUP,
-						   cx, cy,
-						   str_width + FRAME_WIDTH * 2, str_height + FRAME_WIDTH * 2,
-						   src, NULL, hInst, this);
-	}
-
-	tWin->hParentWnd = src;
-	tWin->auto_destroy = TRUE;
-
-	pts.x = cx;
-	pts.y = cy;
-	timerid = NULL;
+	tWin->tip_wnd =
+		CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
+					   (LPCSTR)class_name,
+					   NULL, WS_POPUP,
+					   0, 0,
+					   0, 0,
+					   pHwnd, NULL, hInstance, this);
+	timerid = 0;
 }
 
-VOID CTipWin::GetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height)
+VOID CTipWin::Destroy()
 {
-	TipWinGetTextWidthHeight(src, str, width, height);
+	if(IsExists()) {
+		// \x83t\x83H\x83\x93\x83g\x82̔j\x8A\xFC
+		DeleteObject(tWin->tip_font);
+		tWin->tip_font = NULL;
+		// \x83E\x83B\x83\x93\x83h\x83E\x82̔j\x8A\xFC
+		SetWindowLongPtr(tWin->tip_wnd, GWLP_USERDATA, NULL);
+		DestroyWindow(tWin->tip_wnd);
+		tWin->tip_wnd = NULL;
+	}
 }
 
 POINT CTipWin::GetPos(void)
 {
+	POINT pts;
+	pts.x = tWin->px;
+	pts.y = tWin->py;
 	return pts;
 }
 
@@ -306,10 +310,9 @@
 VOID CTipWin::SetPos(int x, int y)
 {
 	if(IsExists()) {
-		pts.x = x;
-		pts.y = y;
+		tWin->px = x;
+		tWin->py = y;
 		SetWindowPos(tWin->tip_wnd, 0, x, y, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
-
 	}
 }
 
@@ -322,13 +325,6 @@
 	}
 }
 
-VOID CTipWin::Destroy(void)
-{
-	if(IsExists()) {
-		DestroyWindow(tWin->tip_wnd);
-	}
-}
-
 VOID CTipWin::SetHideTimer(int ms)
 {
 	if(IsExists()) {
@@ -339,7 +335,11 @@
 
 BOOL CTipWin::IsExists(void)
 {
-	return (tWin != NULL);
+	if(tWin == NULL)
+		return FALSE;
+	if(tWin->tip_wnd == NULL)
+		return FALSE;
+	return TRUE;
 }
 
 VOID CTipWin::SetVisible(BOOL bVisible)
@@ -362,9 +362,13 @@
 	return FALSE;
 }
 
-TipWin* TipWinCreate(HWND src, int cx, int cy, const TCHAR *str)
+TipWin *TipWinCreate(HINSTANCE hInstance, HWND src, int cx, int cy, const TCHAR *str)
 {
-	CTipWin* tipwin = new CTipWin(src, cx, cy, str);
+	CTipWin* tipwin = new CTipWin(hInstance);
+	tipwin->Create(src);
+	tipwin->SetText((TCHAR*)str);
+	tipwin->SetPos(cx, cy);
+	tipwin->SetVisible(TRUE);
 	return (TipWin*)tipwin;
 }
 
@@ -442,7 +446,8 @@
 void TipWinDestroy(TipWin* tWin)
 {
 	CTipWin* tipwin = (CTipWin*) tWin;
-	tipwin->Destroy();
+	delete(tipwin);
+	tipwin = NULL;
 }
 
 int TipWinIsExists(TipWin *tWin)

Modified: trunk/teraterm/common/tipwin.h
===================================================================
--- trunk/teraterm/common/tipwin.h	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/common/tipwin.h	2019-10-07 13:14:35 UTC (rev 8268)
@@ -35,11 +35,13 @@
 extern "C" {
 #endif
 
-#define	FRAME_WIDTH	6
+#define	TIP_WIN_FRAME_WIDTH	6
 
+#define TipWinClassName _T("TeraTermTipWinClass")
+
 typedef struct tagTipWinData TipWin;
 
-TipWin *TipWinCreate(HWND src, int cx, int cy, const TCHAR *str);
+TipWin *TipWinCreate(HINSTANCE hInstance, HWND src, int cx, int cy, const TCHAR *str);
 void TipWinSetText(TipWin *tWin, TCHAR *text);
 void TipWinDestroy(TipWin *tWin);
 void TipWinGetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height);
@@ -58,26 +60,27 @@
 class CTipWin
 {
 public:
-	CTipWin(HWND hWnd, int x, int y, const TCHAR *str);
-	CTipWin(HWND hWnd);
-	~CTipWin(VOID);
+	CTipWin(HINSTANCE hInstance);
+	~CTipWin();
+	VOID Create(HWND pHwnd);
+	VOID Destroy();
 	VOID SetText(TCHAR *str);
-	VOID Destroy(VOID);
-	VOID GetTextWidthHeight(HWND src, const TCHAR *str, int *width, int *height);
-	POINT GetPos(VOID);
+	POINT GetPos();
 	VOID SetPos(int x, int y);
 	VOID SetHideTimer(int ms);
-	VOID Create(HWND src, int x, int y, const TCHAR *str);
-	BOOL IsExists(VOID);
+	BOOL IsExists();
 	VOID SetVisible(BOOL bVisible);
 	BOOL IsVisible();
 private:
-	POINT pts;
-	UINT timerid;
+	UINT_PTR timerid;
 	TipWin* tWin;
-	static ATOM tip_class;
+	HINSTANCE hInstance;
+	TCHAR class_name[32];
 	static LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam);
-	VOID CalcStrRect(VOID);
+	VOID CalcStrRect();
+	ATOM RegisterClass();
+	BOOL UnregisterClass();
+	BOOL IsClassRegistered();
 };
 #endif
-#endif
\ No newline at end of file
+#endif

Modified: trunk/teraterm/teraterm/addsetting.cpp
===================================================================
--- trunk/teraterm/teraterm/addsetting.cpp	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/teraterm/addsetting.cpp	2019-10-07 13:14:35 UTC (rev 8268)
@@ -635,7 +635,7 @@
 	             _T("Visual"), ts.UILanguageFile);
 	m_psp.pszTitle = _tcsdup(UIMsg);
 	m_psp.dwFlags |= (PSP_USETITLE | PSP_HASHELP);
-	TipWin = new CTipWin(m_hWnd);
+	TipWin = new CTipWin(inst);
 }
 
 CVisualPropPageDlg::~CVisualPropPageDlg()
@@ -642,6 +642,8 @@
 {
 	free((void *)m_psp.pszTitle);
 	TipWin->Destroy();
+	delete TipWin;
+	TipWin = NULL;
 }
 
 // CVisualPropPageDlg \x83\x81\x83b\x83Z\x81[\x83W \x83n\x83\x93\x83h\x83\x89
@@ -809,6 +811,9 @@
 
 	// \x83_\x83C\x83A\x83\x8D\x83O\x82Ƀt\x83H\x81[\x83J\x83X\x82𓖂Ă\xE9
 	::SetFocus(GetDlgItem(IDC_ALPHA_BLEND_ACTIVE));
+
+	// \x83c\x81[\x83\x8B\x83`\x83b\x83v\x8D쐬
+	TipWin->Create(m_hWnd);
 }
 
 void CVisualPropPageDlg::OnHScroll(UINT nSBCode, UINT nPos, HWND pScrollBar)
@@ -1036,7 +1041,7 @@
 				TCHAR uimsg[MAX_UIMSG];
 				RECT rc;
 				get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile);
-				_stprintf_s(tipbuf, _countof(tipbuf), _T(uimsg), (pos / 255.0) * 100);
+				_stprintf_s(tipbuf, _countof(tipbuf), uimsg, (pos / 255.0) * 100);
 
 				::GetWindowRect(GetDlgItem(IDC_ALPHA_BLEND_ACTIVE), &rc);
 				TipWin->SetText(tipbuf);
@@ -1064,7 +1069,7 @@
 				TCHAR tipbuf[32], uimsg[MAX_UIMSG];
 				RECT rc;
 				get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile);
-				_stprintf_s(tipbuf, _countof(tipbuf), _T(uimsg), (pos / 255.0) * 100);
+				_stprintf_s(tipbuf, _countof(tipbuf), uimsg, (pos / 255.0) * 100);
 
 				::GetWindowRect(GetDlgItem(IDC_ALPHA_BLEND_INACTIVE), &rc);
 				TipWin->SetText(tipbuf);

Modified: trunk/teraterm/teraterm/sizetip.c
===================================================================
--- trunk/teraterm/teraterm/sizetip.c	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/teraterm/sizetip.c	2019-10-07 13:14:35 UTC (rev 8268)
@@ -137,14 +137,14 @@
 		GetWindowRect(src, &wr);
 
 		// sizetip\x82\xF0\x8Fo\x82\xB7\x88ʒu\x82́A\x83E\x83B\x83\x93\x83h\x83E\x8D\xB6\x8F\xE3(X, Y)\x82ɑ΂\xB5\x82āA
-		// (X, Y - \x95\xB6\x8E\x9A\x97\xF1\x82̍\x82\x82\xB3 - FRAME_WIDTH * 2) \x82Ƃ\xB7\x82\xE9\x81B
+		// (X, Y - \x95\xB6\x8E\x9A\x97\xF1\x82̍\x82\x82\xB3 - TIP_WIN_FRAME_WIDTH * 2) \x82Ƃ\xB7\x82\xE9\x81B
 		point.x = wr.left;
-		point.y = wr.top - (h + FRAME_WIDTH * 2);
+		point.y = wr.top - (h + TIP_WIN_FRAME_WIDTH * 2);
 		FixPosFromFrame(&point, 16, FALSE);
 		cx = point.x;
 		cy = point.y;
 
-		SizeTip = TipWinCreate(src, cx, cy, str);
+		SizeTip = TipWinCreate(NULL, src, cx, cy, str);
 
 		//OutputDebugPrintf("Created: (%d,%d)\n", cx, cy);
 
@@ -157,7 +157,7 @@
 
 		// \x83E\x83B\x83\x93\x83h\x83E\x82̍\xB6\x8Fオ\x88ړ\xAE\x82\xB7\x82\xE9\x8Fꍇ
 		if (tooltip_movable) {
-			TipWinSetPos(SizeTip, newX + FRAME_WIDTH*2, newY + FRAME_WIDTH*2);
+			TipWinSetPos(SizeTip, newX + TIP_WIN_FRAME_WIDTH*2, newY + TIP_WIN_FRAME_WIDTH*2);
 			//OutputDebugPrintf("Moved: (%d,%d)\n", newX, newY);
 		}
 	}

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/teraterm/vtwin.cpp	2019-10-07 13:14:35 UTC (rev 8268)
@@ -805,11 +805,22 @@
 	DropListCount = 0;
 
 	// TipWin
-	TipWin = new CTipWin(HVTWin);
+	TipWin = new CTipWin(hInstance);
+	TipWin->Create(HVTWin);
 }
 
 /////////////////////////////////////////////////////////////////////////////
+// CVTWindow destructor
 
+CVTWindow::~CVTWindow()
+{
+	TipWin->Destroy();
+	delete TipWin;
+	TipWin = NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
 int CVTWindow::Parse()
 {
 	// added ScrollLock (2006.11.14 yutaka)
@@ -2455,7 +2466,7 @@
 			SetWindowAlpha(newAlpha);
 
 			get_lang_msg("TOOLTIP_TITLEBAR_OPACITY", uimsg, sizeof(uimsg), "Opacity %.1f %%", ts.UILanguageFile);
-			_stprintf_s(tipbuf, _countof(tipbuf), _T(uimsg), (newAlpha / 255.0) * 100);
+			_stprintf_s(tipbuf, _countof(tipbuf), uimsg, (newAlpha / 255.0) * 100);
 
 			tippos = TipWin->GetPos();
 			if (tippos.x != pt.x ||

Modified: trunk/teraterm/teraterm/vtwin.h
===================================================================
--- trunk/teraterm/teraterm/vtwin.h	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/teraterm/vtwin.h	2019-10-07 13:14:35 UTC (rev 8268)
@@ -71,6 +71,7 @@
 
 public:
 	CVTWindow(HINSTANCE hInstance);
+	~CVTWindow();
 	int Parse();
 	void ButtonUp(BOOL Paste);
 	void ButtonDown(POINT p, int LMR);

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2019-10-07 13:14:35 UTC (rev 8268)
@@ -1262,11 +1262,11 @@
 			TipWinGetTextWidthHeight(hWnd, str, &w, &h);
 
 			cx = pt.x;
-			cy = pt.y - (h + FRAME_WIDTH * 6);
+			cy = pt.y - (h + TIP_WIN_FRAME_WIDTH * 6);
 
 			// \x83c\x81[\x83\x8B\x83`\x83b\x83v\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9
 			if (g_SerialDlgSpeedTip == NULL) {
-				g_SerialDlgSpeedTip = TipWinCreate(hWnd, cx, cy, str);
+				g_SerialDlgSpeedTip = TipWinCreate(hInst, hWnd, cx, cy, str);
 				TipWinSetHideTimer(g_SerialDlgSpeedTip, tooltip_timeout);
 
 			} else {

Modified: trunk/ttssh2/ttxssh/auth.c
===================================================================
--- trunk/ttssh2/ttxssh/auth.c	2019-10-06 11:05:26 UTC (rev 8267)
+++ trunk/ttssh2/ttxssh/auth.c	2019-10-07 13:14:35 UTC (rev 8268)
@@ -122,7 +122,7 @@
 					_tcscat_s(uimsg, _countof(uimsg), pvar->ts->UIMsg);
 				}
 				GetWindowRect(control, &rect);
-				data->tipwin = TipWinCreate(control, rect.left, rect.bottom, uimsg);
+				data->tipwin = TipWinCreate(hInst, control, rect.left, rect.bottom, uimsg);
 			}
 
 			return 0;


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