Revision: 7859 https://osdn.net/projects/ttssh2/scm/svn/commits/7859 Author: zmatsuo Date: 2019-07-19 23:33:23 +0900 (Fri, 19 Jul 2019) Log Message: ----------- CenterWindow()で中央に出そうとする元のウィンドウの状態をチェックするようにした - 中央に出そうとする元のウィンドウが非表示状態の場合、 ディスプレイの中央に表示するようにした - る元のウィンドウを指定しない場合も ディスプレイの中央に表示するようにした Modified Paths: -------------- trunk/teraterm/common/ttlib.c -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2019-07-18 14:47:19 UTC (rev 7858) +++ trunk/teraterm/common/ttlib.c 2019-07-19 14:33:23 UTC (rev 7859) @@ -1869,9 +1869,20 @@ } /** - * \x8Ew\x92\xE8\x83E\x83B\x83\x93\x83h\x83E\x82̒\x86\x89\x9B\x82ɃE\x83B\x83\x93\x83h\x83E\x82\xF0\x94z\x92u\x82\xB7\x82\xE9 + * \x83E\x83B\x83\x93\x83h\x83E\x82𒆉\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) + * + * hWndParent\x82̎w\x92肪\x82\xA0\x82\xE9\x8Fꍇ + * hWndParent\x82\xAA\x95\\x8E\xA6\x8F\xF3\x91Ԃ̏ꍇ + * - hWndParent\x82̒\x86\x89\x9B\x82ɔz\x92u + * - \x82\xBD\x82\xBE\x82\xB5\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82\xA9\x82\xE7\x82͂ݏo\x82\xB7\x8Fꍇ\x82͒\xB2\x90\xAE\x82\xB3\x82\xEA\x82\xE9 + * hWndParent\x82\xAA\x94\xF1\x95\\x8E\xA6\x8F\xF3\x91Ԃ̏ꍇ + * - hWnd\x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̒\x86\x89\x9B\x82ɔz\x92u\x82\xB3\x82\xEA\x82\xE9 + * hWndParent\x82\xAANULL\x82̏ꍇ + * - hWnd\x82\xAA\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̒\x86\x89\x9B\x82ɔz\x92u\x82\xB3\x82\xEA\x82\xE9 */ void CenterWindow(HWND hWnd, HWND hWndParent) { @@ -1878,7 +1889,6 @@ RECT rcWnd; LONG WndWidth; LONG WndHeight; - RECT rcParent; int NewX; int NewY; RECT rcDesktop; @@ -1888,15 +1898,28 @@ assert(r != FALSE); (void)r; WndWidth = rcWnd.right - rcWnd.left; WndHeight = rcWnd.bottom - rcWnd.top; - r = GetWindowRect(hWndParent, &rcParent); - assert(r != FALSE); (void)r; - // \x90V\x82\xB5\x82\xA2\x88ʒu - NewX = (rcParent.left + rcParent.right) / 2 - WndWidth / 2; - NewY = (rcParent.top + rcParent.bottom) / 2 - WndHeight / 2; + if (hWndParent == NULL || !IsWindowVisible(hWndParent) || IsIconic(hWndParent)) { + // \x90e\x82\xAA\x90ݒ肳\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 or \x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 or icon\x89\xBB\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9 \x8Fꍇ + // \x83E\x83B\x83\x93\x83h\x83E\x82̕\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83f\x83B\x83X\x83v\x83\x8C\x83C\x82̒\x86\x89\x9B\x82ɕ\\x8E\xA6\x82\xB7\x82\xE9 + GetDesktopRect(hWnd, &rcDesktop); + // \x83f\x83X\x83N\x83g\x83b\x83v(\x95\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83f\x83B\x83X\x83v\x83\x8C\x83C)\x82̒\x86\x89\x9B + NewX = (rcDesktop.left + rcDesktop.right) / 2 - WndWidth / 2; + NewY = (rcDesktop.top + rcDesktop.bottom) / 2 - WndHeight / 2; + } else { + RECT rcParent; + r = GetWindowRect(hWndParent, &rcParent); + assert(r != FALSE); (void)r; + + // hWndParent\x82̒\x86\x89\x9B + NewX = (rcParent.left + rcParent.right) / 2 - WndWidth / 2; + NewY = (rcParent.top + rcParent.bottom) / 2 - WndHeight / 2; + + GetDesktopRect(hWndParent, &rcDesktop); + } + // \x83f\x83X\x83N\x83g\x83b\x83v\x82\xA9\x82\xE7\x82͂ݏo\x82\xB7\x8Fꍇ\x81A\x92\xB2\x90\xAE\x82\xB7\x82\xE9 - GetDesktopRect(hWndParent, &rcDesktop); if (NewX + WndWidth > rcDesktop.right) NewX = rcDesktop.right - WndWidth; if (NewX < rcDesktop.left)