[Ttssh2-commit] [8347] ダイアログがうまくセンタリングできないのを修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 10月 30日 (水) 22:31:54 JST


Revision: 8347
          https://osdn.net/projects/ttssh2/scm/svn/commits/8347
Author:   zmatsuo
Date:     2019-10-30 22:31:53 +0900 (Wed, 30 Oct 2019)
Log Message:
-----------
ダイアログがうまくセンタリングできないのを修正

- inputbox, messagebox, statusbox, passwordbox
- error dialog

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/errdlg.cpp
    trunk/teraterm/ttpmacro/inpdlg.cpp
    trunk/teraterm/ttpmacro/msgdlg.cpp
    trunk/teraterm/ttpmacro/statdlg.cpp

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/errdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/errdlg.cpp	2019-10-30 13:31:42 UTC (rev 8346)
+++ trunk/teraterm/ttpmacro/errdlg.cpp	2019-10-30 13:31:53 UTC (rev 8347)
@@ -75,10 +75,7 @@
 		{ IDCANCEL, "BTN_CONTINUE" },
 		{ IDC_MACROERRHELP, "BTN_HELP" },
 	};
-	RECT R;
-	HDC TmpDC;
 	char buf[MaxLineLen*2], buf2[10];
-	int i, len;
 
 	SetDlgTexts(m_hWnd, TextInfos, _countof(TextInfos), UILanguageFile);
 
@@ -90,9 +87,9 @@
 	_snprintf_s(buf, sizeof(buf), _TRUNCATE, "%s:%d:", MacroFileName, LineNo);
 	SetDlgItemText(IDC_ERRLINE, buf);
 
-	len = strlen(LineStr);
+	size_t len = strlen(LineStr);
 	buf[0] = 0;
-	for (i = 0 ; i < len ; i++) {
+	for (size_t i = 0 ; i < len ; i++) {
 		if (i == StartPos)
 			strncat_s(buf, sizeof(buf), "<<<", _TRUNCATE);
 		if (i == EndPos)
@@ -106,13 +103,14 @@
 	SetDlgItemText(IDC_EDIT_ERRLINE, buf);
 
 	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
-		GetWindowRect(&R);
-		TmpDC = ::GetDC(GetSafeHwnd());
-		PosX = (GetDeviceCaps(TmpDC,HORZRES)-R.right+R.left) / 2;
-		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
-		::ReleaseDC(GetSafeHwnd(),TmpDC);
+		// \x92\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
+		CenterWindow(m_hWnd, m_hParentWnd);
+		// \x88ʒu\x82\xF0\x95ۑ\xB6
+		RECT rcWnd;
+		GetWindowRect(&rcWnd);
+		PosX = rcWnd.left;
+		PosY = rcWnd.top;
 	}
-	SetWindowPos(HWND_TOP, PosX, PosY, 0, 0, SWP_NOSIZE);
 	::SetForegroundWindow(m_hWnd);
 
 	return TRUE;

Modified: trunk/teraterm/ttpmacro/inpdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/inpdlg.cpp	2019-10-30 13:31:42 UTC (rev 8346)
+++ trunk/teraterm/ttpmacro/inpdlg.cpp	2019-10-30 13:31:53 UTC (rev 8347)
@@ -130,7 +130,6 @@
 void CInpDlg::Relocation(BOOL is_init, int new_WW)
 {
 	RECT R;
-	HDC TmpDC;
 	HWND HText, HOk, HEdit;
 	int CW, CH;
 
@@ -172,13 +171,19 @@
 	SendDlgItemMessage(IDC_INPEDIT, EM_LIMITTEXT, MaxStrLen, 0);
 
 	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
-		GetWindowRect(&R);
-		TmpDC = ::GetDC(GetSafeHwnd());
-		PosX = (GetDeviceCaps(TmpDC,HORZRES)-R.right+R.left) / 2;
-		PosY = (GetDeviceCaps(TmpDC,VERTRES)-R.bottom+R.top) / 2;
-		::ReleaseDC(GetSafeHwnd(),TmpDC);
+		// \x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x83Z\x83b\x83g
+		::SetWindowPos(m_hWnd, HWND_TOP,0,0,WW,WH,SWP_NOMOVE);
+		// \x92\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
+		CenterWindow(m_hWnd, m_hParentWnd);
+		// \x88ʒu\x82\xF0\x95ۑ\xB6
+		RECT rcWnd;
+		GetWindowRect(&rcWnd);
+		PosX = rcWnd.left;
+		PosY = rcWnd.top;
+	} else {
+		// \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);
 	}
-	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,0);
 
 	InvalidateRect(NULL, TRUE);
 }

Modified: trunk/teraterm/ttpmacro/msgdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/msgdlg.cpp	2019-10-30 13:31:42 UTC (rev 8346)
+++ trunk/teraterm/ttpmacro/msgdlg.cpp	2019-10-30 13:31:53 UTC (rev 8347)
@@ -125,7 +125,6 @@
 void CMsgDlg::Relocation(BOOL is_init, int new_WW)
 {
 	RECT R;
-	HDC TmpDC;
 	HWND HText, HOk, HNo;
 	int CW, CH;
 
@@ -167,12 +166,20 @@
 	}
 
 	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
-		TmpDC = ::GetDC(GetSafeHwnd());
-		PosX = (GetDeviceCaps(TmpDC,HORZRES)-WW) / 2;
-		PosY = (GetDeviceCaps(TmpDC,VERTRES)-WH) / 2;
-		::ReleaseDC(GetSafeHwnd(),TmpDC);
+		// \x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x83Z\x83b\x83g
+		::SetWindowPos(m_hWnd, HWND_TOP,0,0,WW,WH,SWP_NOMOVE);
+		// \x92\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
+		CenterWindow(m_hWnd, m_hParentWnd);
+		// \x88ʒu\x82\xF0\x95ۑ\xB6
+		RECT rcWnd;
+		GetWindowRect(&rcWnd);
+		PosX = rcWnd.left;
+		PosY = rcWnd.top;
+	} else {
+		// \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);
 	}
-	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,0);
+
 	InvalidateRect(NULL);
 }
 

Modified: trunk/teraterm/ttpmacro/statdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/statdlg.cpp	2019-10-30 13:31:42 UTC (rev 8346)
+++ trunk/teraterm/ttpmacro/statdlg.cpp	2019-10-30 13:31:53 UTC (rev 8347)
@@ -176,7 +176,6 @@
 void CStatDlg::Relocation(BOOL is_init, int new_WW)
 {
 	RECT R;
-	HDC TmpDC;
 	HWND HText;
 	int CW, CH;
 
@@ -207,12 +206,19 @@
 	}
 
 	if (PosX<=GetMonitorLeftmost(PosX, PosY)-100) {
-		TmpDC = ::GetDC(GetSafeHwnd());
-		PosX = (GetDeviceCaps(TmpDC,HORZRES)-WW) / 2;
-		PosY = (GetDeviceCaps(TmpDC,VERTRES)-WH) / 2;
-		::ReleaseDC(GetSafeHwnd(),TmpDC);
+		// \x83E\x83B\x83\x93\x83h\x83E\x83T\x83C\x83Y\x82\xF0\x83Z\x83b\x83g
+		::SetWindowPos(m_hWnd, HWND_TOP,0,0,WW,WH,SWP_NOMOVE);
+		// \x92\x86\x89\x9B\x82Ɉړ\xAE\x82\xB7\x82\xE9
+		CenterWindow(m_hWnd, NULL);
+		// \x88ʒu\x82\xF0\x95ۑ\xB6
+		RECT rcWnd;
+		GetWindowRect(&rcWnd);
+		PosX = rcWnd.left;
+		PosY = rcWnd.top;
+	} else {
+		// \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);
 	}
-	SetWindowPos(HWND_TOP,PosX,PosY,WW,WH,SWP_NOZORDER);
 
 	InvalidateRect(NULL, TRUE);
 }


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