[ttssh2-commit] [10011] tipwin2追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 6月 24日 (金) 23:03:20 JST


Revision: 10011
          https://osdn.net/projects/ttssh2/scm/svn/commits/10011
Author:   zmatsuo
Date:     2022-06-24 23:03:19 +0900 (Fri, 24 Jun 2022)
Log Message:
-----------
tipwin2追加

- sendfiledlg.cpp から分離
- common contol の TOOLTIPS_CLASS を使用したツールチップ

Modified Paths:
--------------
    trunk/teraterm/common/CMakeLists.txt
    trunk/teraterm/common/common_static.v16.vcxproj
    trunk/teraterm/common/common_static.v8.vcproj
    trunk/teraterm/teraterm/sendfiledlg.cpp

Added Paths:
-----------
    trunk/teraterm/common/tipwin2.cpp
    trunk/teraterm/common/tipwin2.h

-------------- next part --------------
Modified: trunk/teraterm/common/CMakeLists.txt
===================================================================
--- trunk/teraterm/common/CMakeLists.txt	2022-06-24 14:03:07 UTC (rev 10010)
+++ trunk/teraterm/common/CMakeLists.txt	2022-06-24 14:03:19 UTC (rev 10011)
@@ -29,6 +29,8 @@
   inifile_com.cpp
   tipwin.cpp
   tipwin.h
+  tipwin2.cpp
+  tipwin2.h
   tmfc.cpp
   tmfc.h
   tmfc_frame.cpp

Modified: trunk/teraterm/common/common_static.v16.vcxproj
===================================================================
--- trunk/teraterm/common/common_static.v16.vcxproj	2022-06-24 14:03:07 UTC (rev 10010)
+++ trunk/teraterm/common/common_static.v16.vcxproj	2022-06-24 14:03:19 UTC (rev 10011)
@@ -139,6 +139,7 @@
     <ClCompile Include="fileread.cpp" />
     <ClCompile Include="inifile_com.cpp" />
     <ClCompile Include="tipwin.cpp" />
+    <ClCompile Include="tipwin2.cpp" />
     <ClCompile Include="tmfc.cpp" />
     <ClCompile Include="tmfc_frame.cpp" />
     <ClCompile Include="tmfc_propdlg.cpp" />
@@ -162,6 +163,7 @@
     <ClInclude Include="fileread.h" />
     <ClInclude Include="inifile_com.h" />
     <ClInclude Include="tipwin.h" />
+    <ClInclude Include="tipwin2.h" />
     <ClInclude Include="tmfc.h" />
     <ClInclude Include="compat_win.h" />
     <ClInclude Include="dllutil.h" />

Modified: trunk/teraterm/common/common_static.v8.vcproj
===================================================================
--- trunk/teraterm/common/common_static.v8.vcproj	2022-06-24 14:03:07 UTC (rev 10010)
+++ trunk/teraterm/common/common_static.v8.vcproj	2022-06-24 14:03:19 UTC (rev 10011)
@@ -265,6 +265,14 @@
 			>
 		</File>
 		<File
+			RelativePath=".\tipwin2.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\tipwin2.h"
+			>
+		</File>
+		<File
 			RelativePath=".\tmfc.cpp"
 			>
 		</File>

Added: trunk/teraterm/common/tipwin2.cpp
===================================================================
--- trunk/teraterm/common/tipwin2.cpp	                        (rev 0)
+++ trunk/teraterm/common/tipwin2.cpp	2022-06-24 14:03:19 UTC (rev 10011)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022- TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *	common contol \x82\xCC TOOLTIPS_CLASS \x82\xF0\x8Eg\x97p\x82\xB5\x82\xBD\x83c\x81[\x83\x8B\x83`\x83b\x83v
+ */
+#include <windows.h>
+#include <commctrl.h>
+
+#include "tipwin2.h"
+
+typedef struct tagTipWinData {
+	HWND hDlg;
+	HWND hTip;
+} TipWin2;
+
+TipWin2 *TipWin2Create(HINSTANCE hInstance, HWND hDlg)
+{
+	HINSTANCE hInst = hInstance;
+	if (hInstance == NULL) {
+		hInst = (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE);
+	}
+
+	HWND hTip = CreateWindowExW(NULL, TOOLTIPS_CLASSW, NULL,
+								WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
+								CW_USEDEFAULT, CW_USEDEFAULT,
+								CW_USEDEFAULT, CW_USEDEFAULT,
+								hDlg, NULL,
+								hInst, NULL);
+	if (hTip == NULL) {
+		return NULL;
+	}
+	SendMessageW(hTip, TTM_SETMAXTIPWIDTH, 0, INT_MAX);
+
+	TipWin2 *tWin = (TipWin2 *)calloc(sizeof(TipWin2), 1);
+	if (tWin == NULL) {
+		return NULL;
+	}
+	tWin->hTip = hTip;
+	tWin->hDlg = hDlg;
+
+	return tWin;
+}
+
+void TipWin2Destroy(TipWin2 *tWin)
+{
+	DestroyWindow(tWin->hTip);
+	tWin->hTip = NULL;
+	free(tWin);
+}
+
+/**
+ * @brief \x83c\x81[\x83\x8B\x83`\x83b\x83v\x82\xF0\x93o\x98^\x82\xB7\x82\xE9
+ * @param tWin
+ * @param id \x83_\x83C\x83A\x83\x8D\x83O\x82̃R\x83\x93\x83g\x83\x8D\x81[\x83\x8BID
+ * @param text \x83c\x81[\x83\x8B\x83`\x83b\x83v
+ */
+void TipWin2SetTextW(TipWin2 *tWin, int id, const wchar_t *text)
+{
+	TOOLINFOW toolInfo = {};
+	toolInfo.cbSize = sizeof(toolInfo);
+	toolInfo.hwnd = tWin->hDlg;
+	toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;	// TTF_IDISHWND \x82\xAA\x82\xA0\x82\xEA\x82\xCErect\x82͎Q\x8FƂ\xB3\x82\xEA\x82Ȃ\xA2
+	toolInfo.uId = (UINT_PTR)GetDlgItem(tWin->hDlg, id);
+	toolInfo.lpszText = (LPWSTR)text;	// text \x82\xCD SendMessage() \x8E\x9E\x82ɑ\xB6\x8D݂\xB7\x82\xEA\x82Ηǂ\xA2
+	SendMessageW(tWin->hTip, TTM_ADDTOOLW, 0, (LPARAM)&toolInfo);
+}

Added: trunk/teraterm/common/tipwin2.h
===================================================================
--- trunk/teraterm/common/tipwin2.h	                        (rev 0)
+++ trunk/teraterm/common/tipwin2.h	2022-06-24 14:03:19 UTC (rev 10011)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2022- TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct tagTipWinData TipWin2;
+
+TipWin2 *TipWin2Create(HINSTANCE hInstance, HWND hDlg);
+void TipWin2Destroy(TipWin2 *tWin);
+void TipWin2SetTextW(TipWin2 *tWin, int id, const wchar_t *text);
+
+#ifdef __cplusplus
+}
+#endif

Modified: trunk/teraterm/teraterm/sendfiledlg.cpp
===================================================================
--- trunk/teraterm/teraterm/sendfiledlg.cpp	2022-06-24 14:03:07 UTC (rev 10010)
+++ trunk/teraterm/teraterm/sendfiledlg.cpp	2022-06-24 14:03:19 UTC (rev 10011)
@@ -43,62 +43,10 @@
 #include "codeconv.h"
 #include "asprintf.h"
 #include "win32helper.h"
+#include "tipwin2.h"
 
 #include "sendfiledlg.h"
 
-typedef struct tagTipWinData {
-	HWND hDlg;
-	HWND hTip;
-} TipWin2;
-
-static TipWin2 *TipWin2Create(HINSTANCE hInstance, HWND hDlg)
-{
-	HINSTANCE hInst = hInstance;
-	if (hInstance == NULL) {
-		hInst = (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE);
-	}
-
-	HWND hTip = CreateWindowExW(NULL, TOOLTIPS_CLASSW, NULL,
-								WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON,
-								CW_USEDEFAULT, CW_USEDEFAULT,
-								CW_USEDEFAULT, CW_USEDEFAULT,
-								hDlg, NULL,
-								hInst, NULL);
-	if (hTip == NULL) {
-		return NULL;
-	}
-	SendMessageW(hTip, TTM_SETMAXTIPWIDTH, 0, INT_MAX);
-
-	TipWin2 *tWin = (TipWin2 *)calloc(sizeof(TipWin2), 1);
-	if (tWin == NULL) {
-		return NULL;
-	}
-	tWin->hTip = hTip;
-	tWin->hDlg = hDlg;
-
-	return tWin;
-}
-
-static void TipWin2Destroy(TipWin2 *tWin)
-{
-	DestroyWindow(tWin->hTip);
-	tWin->hTip = NULL;
-	free(tWin);
-}
-
-static BOOL TipWin2SetTextW(TipWin2 *tWin, int id, const wchar_t *text)
-{
-	TOOLINFOW toolInfo = {};
-	toolInfo.cbSize = sizeof(toolInfo);
-	toolInfo.hwnd = tWin->hDlg;
-	toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;	// TTF_IDISHWND \x82\xAA\x82\xA0\x82\xEA\x82\xCErect\x82͎Q\x8FƂ\xB3\x82\xEA\x82Ȃ\xA2
-	toolInfo.uId = (UINT_PTR)GetDlgItem(tWin->hDlg, id);
-	toolInfo.lpszText = (LPWSTR)text;	// text \x82\xCD SendMessage() \x8E\x9E\x82ɑ\xB6\x8D݂\xB7\x82\xEA\x82Ηǂ\xA2
-	SendMessageW(tWin->hTip, TTM_ADDTOOLW, 0, (LPARAM)&toolInfo);
-
-	return TRUE;
-}
-
 typedef struct {
 	sendfiledlgdata *create_param;
 	// work


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