[Ttssh2-commit] [8408] setdlgposの位置指定でダイアログがディスプレイからはみ出さないようにした

scmno****@osdn***** scmno****@osdn*****
2019年 11月 25日 (月) 21:57:48 JST


Revision: 8408
          https://osdn.net/projects/ttssh2/scm/svn/commits/8408
Author:   zmatsuo
Date:     2019-11-25 21:57:48 +0900 (Mon, 25 Nov 2019)
Log Message:
-----------
setdlgposの位置指定でダイアログがディスプレイからはみ出さないようにした

- ダイアログが必ずディスプレイ内に表示されるようにする [Ttssh2-devel 4385]
- MoveWindowToDisplay()@ttlib.c を作成
  - ディスプレイからはみ出す場合、ウィンドウをディスプレイ内に移動する
  - clipboard確認ダイアログのディスプレイ内に移動するコード関数化
- マクロのダイアログを表示する際 MoveWindowToDisplay() をコール
  - マクロコマンドsetdlgpos でディスプレイ外を指定されてもディスプレイ内に表示

Modified Paths:
--------------
    trunk/teraterm/common/ttlib.c
    trunk/teraterm/common/ttlib.h
    trunk/teraterm/teraterm/clipboar.c
    trunk/teraterm/ttpmacro/macrodlgbase.h

-------------- next part --------------
Modified: trunk/teraterm/common/ttlib.c
===================================================================
--- trunk/teraterm/common/ttlib.c	2019-11-25 12:57:39 UTC (rev 8407)
+++ trunk/teraterm/common/ttlib.c	2019-11-25 12:57:48 UTC (rev 8408)
@@ -1869,9 +1869,54 @@
 }
 
 /**
- *	\x83E\x83B\x83\x93\x83h\x83E\x82𒆉\x9B\x82ɔz\x92u\x82\xB7\x82\xE9
+ *	\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82\xA9\x82\xE7\x82͂ݏo\x82\xB3\x82Ȃ\xA2\x82悤\x82Ɉړ\xAE\x82\xB7\x82\xE9
+ *	\x82͂ݏo\x82Ă\xA2\x82Ȃ\xA2\x8Fꍇ\x82͈ړ\xAE\x82\xB5\x82Ȃ\xA2
  *
  *	@param[in]	hWnd		\x88ʒu\x82𒲐\xAE\x82\xB7\x82\xE9\x83E\x83B\x83\x93\x83h\x83E
+ */
+void MoveWindowToDisplay(HWND hWnd)
+{
+	RECT desktop;
+	RECT win_rect;
+	int win_width;
+	int win_height;
+	int win_x;
+	int win_y;
+	BOOL modify = FALSE;
+
+	GetDesktopRect(hWnd, &desktop);
+
+	GetWindowRect(hWnd, &win_rect);
+	win_x = win_rect.left;
+	win_y = win_rect.top;
+	win_height = win_rect.bottom - win_rect.top;
+	win_width = win_rect.right - win_rect.left;
+	if (win_y < desktop.top) {
+		win_y = desktop.top;
+		modify = TRUE;
+	}
+	else if (win_y + win_height > desktop.bottom) {
+		win_y = desktop.bottom - win_height;
+		modify = TRUE;
+	}
+	if (win_x < desktop.left) {
+		win_x = desktop.left;
+		modify = TRUE;
+	}
+	else if (win_x + win_width > desktop.right) {
+		win_x = desktop.right - win_width;
+		modify = TRUE;
+	}
+
+	if (modify) {
+		SetWindowPos(hWnd, NULL, win_x, win_y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+	}
+}
+
+/**
+ *	\x83E\x83B\x83\x93\x83h\x83E\x82\xF0\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̒\x86\x89\x9B\x82ɔz\x92u\x82\xB7\x82\xE9
+ *
+ *	@param[in]	hWnd		\x88ʒu\x82𒲐\xAE\x82\xB7\x82\xE9\x83E\x83B\x83\x93\x83h\x83E
  *	@param[in]	hWndParent	\x82\xB1\x82̃E\x83B\x83\x93\x83h\x83E\x82̒\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
  *							(NULL\x82̏ꍇ\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̒\x86\x89\x9B)
  *

Modified: trunk/teraterm/common/ttlib.h
===================================================================
--- trunk/teraterm/common/ttlib.h	2019-11-25 12:57:39 UTC (rev 8407)
+++ trunk/teraterm/common/ttlib.h	2019-11-25 12:57:48 UTC (rev 8408)
@@ -119,6 +119,7 @@
 DllExport void GetMessageboxFont(LOGFONTA *logfont);
 void GetDesktopRect(HWND hWnd, RECT *rect);
 void CenterWindow(HWND hWnd, HWND hWndParent);
+void MoveWindowToDisplay(HWND hWnd);
 
 #define CheckFlag(var, flag)	(((var) & (flag)) != 0)
 

Modified: trunk/teraterm/teraterm/clipboar.c
===================================================================
--- trunk/teraterm/teraterm/clipboar.c	2019-11-25 12:57:39 UTC (rev 8407)
+++ trunk/teraterm/teraterm/clipboar.c	2019-11-25 12:57:48 UTC (rev 8408)
@@ -866,8 +866,7 @@
 		{ IDOK, "BTN_OK" },
 	};
 	POINT p;
-	RECT rc_dsk, rc_dlg;
-	int dlg_height, dlg_width;
+	RECT rc_dlg;
 	static int ok2right, edit2ok, edit2bottom;
 	RECT rc_edit, rc_ok, rc_cancel;
 	// for status bar
@@ -903,45 +902,9 @@
 			}
 
 			ClientToScreen(GetParent(hDlgWnd), &p);
-
-			// \x83L\x83\x83\x83\x8C\x83b\x83g\x82\xAA\x89\xE6\x96ʂ\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x82ɓ\\x82\xE8\x95t\x82\xAF\x82\xF0\x82\xB7\x82\xE9\x82\xC6
-			// \x8Am\x94F\x83E\x83C\x83\x93\x83h\x83E\x82\xAA\x8C\xA9\x82\xA6\x82\xE9\x82Ƃ\xB1\x82\xEB\x82ɕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA\x82\xA0\x82\xE9\x81B
-			// \x83E\x83C\x83\x93\x83h\x83E\x82\xA9\x82\xE7\x82͂ݏo\x82\xB5\x82\xBD\x8Fꍇ\x82ɒ\xB2\x90߂\xB7\x82\xE9 (2008.4.24 maya)
-			if (!HasMultiMonitorSupport()) {
-				// NT4.0, 95 \x82̓}\x83\x8B\x83`\x83\x82\x83j\x83^API\x82ɔ\xF1\x91Ή\x9E
-				SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0);
-			}
-			else {
-				HMONITOR hm;
-				POINT pt;
-				MONITORINFO mi;
-
-				pt.x = p.x;
-				pt.y = p.y;
-				hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
-
-				mi.cbSize = sizeof(MONITORINFO);
-				GetMonitorInfo(hm, &mi);
-				rc_dsk = mi.rcWork;
-			}
-			GetWindowRect(hDlgWnd, &rc_dlg);
-			dlg_height = rc_dlg.bottom-rc_dlg.top;
-			dlg_width  = rc_dlg.right-rc_dlg.left;
-			if (p.y < rc_dsk.top) {
-				p.y = rc_dsk.top;
-			}
-			else if (p.y + dlg_height > rc_dsk.bottom) {
-				p.y = rc_dsk.bottom - dlg_height;
-			}
-			if (p.x < rc_dsk.left) {
-				p.x = rc_dsk.left;
-			}
-			else if (p.x + dlg_width > rc_dsk.right) {
-				p.x = rc_dsk.right - dlg_width;
-			}
-
 			SetWindowPos(hDlgWnd, NULL, p.x, p.y,
 			             0, 0, SWP_NOSIZE | SWP_NOZORDER);
+			MoveWindowToDisplay(hDlgWnd);
 
 			// \x83_\x83C\x83A\x83\x8D\x83O\x82̏\x89\x8A\xFA\x83T\x83C\x83Y\x82\xF0\x95ۑ\xB6
 			GetWindowRect(hDlgWnd, &rc_dlg);

Modified: trunk/teraterm/ttpmacro/macrodlgbase.h
===================================================================
--- trunk/teraterm/ttpmacro/macrodlgbase.h	2019-11-25 12:57:39 UTC (rev 8407)
+++ trunk/teraterm/ttpmacro/macrodlgbase.h	2019-11-25 12:57:48 UTC (rev 8408)
@@ -54,6 +54,7 @@
 			// \x83E\x83B\x83\x93\x83h\x83E\x88ʒu\x82̂ݐݒ肷\x82\xE9 errdlg
 			if (IsValidPos()) {
 				::SetWindowPos(m_hWnd, HWND_TOP, PosX, PosY, 0, 0, SWP_NOSIZE);
+				MoveWindowToDisplay(m_hWnd);
 			}
 			else {
 				// \x92\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
@@ -70,6 +71,7 @@
 			if (IsValidPos()) {
 				// \x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x83Z\x83b\x83g + \x8Ew\x92\xE8\x88ʒu\x82ֈړ\xAE
 				::SetWindowPos(m_hWnd, HWND_TOP, PosX, PosY, WW, WH, 0);
+				MoveWindowToDisplay(m_hWnd);
 			}
 			else {
 				// \x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x83Z\x83b\x83g


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