[Ttssh2-commit] [6888] 現在のウィンドウ数を返す関数を作り、vtwin.cpp ではそれを使うように変更。

svnno****@sourc***** svnno****@sourc*****
2017年 7月 26日 (水) 12:47:58 JST


Revision: 6888
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6888
Author:   doda
Date:     2017-07-26 12:47:58 +0900 (Wed, 26 Jul 2017)
Log Message:
-----------
現在のウィンドウ数を返す関数を作り、vtwin.cpp ではそれを使うように変更。

ループで無理やり数えるくらいならば、pm->NWin を見せるようにする方がいいと思う。
本当は各ウィンドウに対して処理を行うようなイテレータを ttpcmn.dll が提供する方がいいのかもしれないけれど。

Modified Paths:
--------------
    trunk/teraterm/common/ttcommon.h
    trunk/teraterm/teraterm/vtwin.cpp
    trunk/teraterm/ttpcmn/ttcmn.c
    trunk/teraterm/ttpcmn/ttpcmn.def

-------------- next part --------------
Modified: trunk/teraterm/common/ttcommon.h
===================================================================
--- trunk/teraterm/common/ttcommon.h	2017-07-26 03:47:55 UTC (rev 6887)
+++ trunk/teraterm/common/ttcommon.h	2017-07-26 03:47:58 UTC (rev 6888)
@@ -60,6 +60,7 @@
 void PASCAL SelectWin(int WinId);
 void PASCAL SelectNextWin(HWND HWin, int Next, BOOL SkipIconic);
 HWND PASCAL GetNthWin(int n);
+int PASCAL GetRegisteredWindowCount();
 void PASCAL ShowAllWin(int stat);
 void PASCAL ShowAllWinSidebySide(HWND);
 void PASCAL ShowAllWinStacked(HWND);

Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2017-07-26 03:47:55 UTC (rev 6887)
+++ trunk/teraterm/teraterm/vtwin.cpp	2017-07-26 03:47:58 UTC (rev 6888)
@@ -5545,30 +5545,16 @@
 	return FALSE;
 }
 
-
-static int GetApplicationInstanceCount(void)
-{
-	int i;
-	HWND hd;
-
-	for (i = 0 ; i < MAXNWIN ; i++) {
-		hd = GetNthWin(i);
-		if (hd == NULL) {
-			break;
-		}
-	}
-	return (i);
-}
-
 static void UpdateBroadcastWindowList(HWND hWnd)
 {
-	int i;
+	int i, count;
 	HWND hd;
 	TCHAR szWindowText[256];
 
 	SendMessage(hWnd, LB_RESETCONTENT, 0, 0);
 
-	for (i = 0 ; i < MAXNWIN ; i++) {
+	count = GetRegisteredWindowCount();
+	for (i = 0 ; i < count ; i++) {
 		hd = GetNthWin(i);
 		if (hd == NULL) {
 			break;
@@ -5621,7 +5607,7 @@
 extern "C"
 void SendBroadcastMessage(HWND HVTWin, HWND hWnd, char *buf, int buflen)
 {
-	int i;
+	int i, count;
 	HWND hd;
 	COPYDATASTRUCT cds;
 
@@ -5630,8 +5616,10 @@
 	cds.cbData = buflen;
 	cds.lpData = buf;
 
+	count = GetRegisteredWindowCount();
+
 	// \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9\x81B
-	for (i = 0 ; i < MAXNWIN ; i++) {
+	for (i = 0 ; i < count ; i++) {
 		if ((hd = GetNthWin(i)) == NULL) {
 			break;
 		}
@@ -5649,7 +5637,7 @@
 extern "C"
 void SendMulticastMessage(HWND HVTWin, HWND hWnd, char *name, char *buf, int buflen)
 {
-	int i;
+	int i, count;
 	HWND hd;
 	COPYDATASTRUCT cds;
 	char *msg = NULL;
@@ -5678,8 +5666,10 @@
 	cds.cbData = msglen;
 	cds.lpData = msg;
 
+	count = GetRegisteredWindowCount();
+
 	// \x82\xB7\x82ׂĂ\xCCTera Term\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82ƃf\x81[\x83^\x82𑗂\xE9
-	for (i = 0 ; i < MAXNWIN ; i++) {
+	for (i = 0 ; i < count ; i++) {
 		if ((hd = GetNthWin(i)) == NULL) {
 			break;
 		}
@@ -6084,7 +6074,7 @@
 				if (wp != list_timer_id)
 					break;
 
-				n = GetApplicationInstanceCount();
+				n = GetRegisteredWindowCount();
 				if (n != prev_instances) {
 					prev_instances = n;
 					UpdateBroadcastWindowList(BroadcastWindowList);
@@ -6099,7 +6089,7 @@
 					int i, n;
 
 					//OutputDebugPrintf("msg %x wp %x lp %x\n", msg, wp, lp);
-					n = GetApplicationInstanceCount();
+					n = GetRegisteredWindowCount();
 					for (i = 0 ; i < n ; i++) {
 						ListBox_SetSel(BroadcastWindowList, TRUE, i);
 					}

Modified: trunk/teraterm/ttpcmn/ttcmn.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn.c	2017-07-26 03:47:55 UTC (rev 6887)
+++ trunk/teraterm/ttpcmn/ttcmn.c	2017-07-26 03:47:58 UTC (rev 6888)
@@ -1187,6 +1187,10 @@
 	}
 }
 
+int PASCAL GetRegisteredWindowCount()
+{
+	return (pm->NWin);
+}
 
 // \x97L\x8C\xF8\x82ȃE\x83B\x83\x93\x83h\x83E\x82\xF0\x92T\x82\xB5\x81A\x8C\xBB\x8D݈ʒu\x82\xF0\x8BL\x89\xAF\x82\xB3\x82\xB9\x82Ă\xA8\x82\xAD\x81B
 static void get_valid_window_and_memorize_rect(HWND myhwnd, HWND hwnd[], int *num, int style)

Modified: trunk/teraterm/ttpcmn/ttpcmn.def
===================================================================
--- trunk/teraterm/ttpcmn/ttpcmn.def	2017-07-26 03:47:55 UTC (rev 6887)
+++ trunk/teraterm/ttpcmn/ttpcmn.def	2017-07-26 03:47:58 UTC (rev 6888)
@@ -14,6 +14,7 @@
   SelectWin @14
   SelectNextWin @15
   GetNthWin @16
+  GetRegisteredWindowCount @89
   ShowAllWin @54
   CommReadRawByte @20
   CommInsert1Byte @21



Ttssh2-commit メーリングリストの案内