[Ttssh2-commit] [3841] ShowShow Macro Windowにおいて、statusbox をフォアグラウンド化できるようにした。

svnno****@sourc***** svnno****@sourc*****
2010年 4月 4日 (日) 23:45:45 JST


Revision: 3841
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3841
Author:   yutakapon
Date:     2010-04-04 23:45:45 +0900 (Sun, 04 Apr 2010)

Log Message:
-----------
ShowShow Macro Windowにおいて、statusbox をフォアグラウンド化できるようにした。
cf.
http://d.hatena.ne.jp/gsf_zero1/20071211/p1

Modified Paths:
--------------
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/ttdde.c
    trunk/teraterm/ttpmacro/statdlg.cpp
    trunk/teraterm/ttpmacro/statdlg.h


-------------- next part --------------
Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2010-04-04 14:05:13 UTC (rev 3840)
+++ trunk/teraterm/common/tttypes.h	2010-04-04 14:45:45 UTC (rev 3841)
@@ -129,6 +129,8 @@
 #define WM_USER_DDECOMREADY  WM_USER+23
 #define WM_USER_DDEEND       WM_USER+24
 
+#define MY_FORCE_FOREGROUND_MESSAGE	WM_USER+31
+
   /* port type ID */
 #define IdTCPIP  1
 #define IdSerial 2

Modified: trunk/teraterm/teraterm/ttdde.c
===================================================================
--- trunk/teraterm/teraterm/ttdde.c	2010-04-04 14:05:13 UTC (rev 3840)
+++ trunk/teraterm/teraterm/ttdde.c	2010-04-04 14:45:45 UTC (rev 3841)
@@ -1100,17 +1100,24 @@
 	if ((FName == NULL && Startup == FALSE) && ConvH != 0) {
 		HWND hwnd;
 		DWORD pid_macro, pid;
+		DWORD targetid;
+		DWORD currentActiveThreadId;
 
+		currentActiveThreadId = GetWindowThreadProcessId(GetForegroundWindow(), &pid);
+
 		GetWindowThreadProcessId(HWndDdeCli, &pid_macro);
 		hwnd = GetTopWindow(NULL);
 		while (hwnd) {
-			GetWindowThreadProcessId(hwnd, &pid);
+			targetid = GetWindowThreadProcessId(hwnd, &pid);
 			if (pid == pid_macro) {
 				FlashWindow(hwnd, TRUE);
+
+				SendMessage(hwnd, MY_FORCE_FOREGROUND_MESSAGE, (WPARAM)hwnd, 0);
 			}
 			hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
 		}
 
+		// ƒ}ƒNƒƒEƒBƒ“ƒhƒE–{‘Ì
 		ShowWindow(HWndDdeCli, SW_NORMAL);
 		SetForegroundWindow(HWndDdeCli);
 		BringWindowToTop(HWndDdeCli);

Modified: trunk/teraterm/ttpmacro/statdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/statdlg.cpp	2010-04-04 14:05:13 UTC (rev 3840)
+++ trunk/teraterm/ttpmacro/statdlg.cpp	2010-04-04 14:45:45 UTC (rev 3841)
@@ -11,6 +11,7 @@
 #include "ttmlib.h"
 
 #include "statdlg.h"
+#include "tttypes.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -23,6 +24,7 @@
 BEGIN_MESSAGE_MAP(CStatDlg, CDialog)
 	//{{AFX_MSG_MAP(CStatDlg)
 	ON_MESSAGE(WM_EXITSIZEMOVE, OnExitSizeMove)
+	ON_MESSAGE(MY_FORCE_FOREGROUND_MESSAGE, OnSetForceForegroundWindow)
 	//}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -140,6 +142,28 @@
 	return CDialog::DefWindowProc(WM_EXITSIZEMOVE,wParam,lParam);
 }
 
+LONG CStatDlg::OnSetForceForegroundWindow(UINT wParam, LONG lParam)
+{
+	DWORD pid;
+	DWORD targetid;
+	DWORD currentActiveThreadId;
+	HWND hwnd = (HWND)wParam;
+
+	targetid = GetWindowThreadProcessId(hwnd, &pid);
+	currentActiveThreadId = GetWindowThreadProcessId(::GetForegroundWindow(), &pid);
+
+	SetForegroundWindow();
+	if (targetid == currentActiveThreadId) {
+		BringWindowToTop();
+	} else {
+		AttachThreadInput(targetid, currentActiveThreadId, TRUE);
+		BringWindowToTop();
+		AttachThreadInput(targetid, currentActiveThreadId, FALSE);
+	}
+
+	return TRUE;
+}
+
 void CStatDlg::Relocation(BOOL is_init, int new_WW)
 {
 	RECT R;

Modified: trunk/teraterm/ttpmacro/statdlg.h
===================================================================
--- trunk/teraterm/ttpmacro/statdlg.h	2010-04-04 14:05:13 UTC (rev 3840)
+++ trunk/teraterm/ttpmacro/statdlg.h	2010-04-04 14:45:45 UTC (rev 3841)
@@ -31,6 +31,7 @@
 	//{{AFX_MSG(CStatDlg)
 	virtual BOOL OnInitDialog();
 	afx_msg LONG OnExitSizeMove(UINT wParam, LONG lParam);
+	afx_msg LONG OnSetForceForegroundWindow(UINT wParam, LONG lParam);
 	//}}AFX_MSG
 	void Relocation(BOOL is_init, int WW);
 	DECLARE_MESSAGE_MAP()



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