From 04a7134b971c91bd9f10ff3a4369e76cbe28ea74 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Fri, 14 Jan 2022 12:44:29 +0900 Subject: [PATCH] [MSGINA] Adjust Status Window if Asian The Asian logo and bar positions are different from English or Latin positions, due to Asian font. Add positional adjustment to IDD_STATUS if Asian. Follow-up of #4280 ef4f0d0. --- dll/win32/msgina/gui.c | 65 ++++++++++++++++++++++++++++++++++ dll/win32/msgina/lang/ja-JP.rc | 6 ++-- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/dll/win32/msgina/gui.c b/dll/win32/msgina/gui.c index 7254b871709..d46126d3c25 100644 --- a/dll/win32/msgina/gui.c +++ b/dll/win32/msgina/gui.c @@ -181,6 +181,69 @@ done: RegCloseKey(hKey); } +static VOID +AdjustStatusMessageWindow(HWND hwndDlg, PDLG_DATA pDlgData) +{ + INT xOld, yOld, cxOld, cyOld; + INT xNew, yNew, cxNew, cyNew; + INT cxLabel, cyLabel, dyLabel; + RECT rc, rcBar, rcLabel, rcWnd; + BITMAP bmLogo, bmBar; + DWORD style, exstyle; + HWND hwndLogo = GetDlgItem(hwndDlg, IDC_ROSLOGO); + HWND hwndBar = GetDlgItem(hwndDlg, IDC_BAR); + HWND hwndLabel = GetDlgItem(hwndDlg, IDC_STATUS_MESSAGE); + + /* This adjustment is for CJK only */ + switch (PRIMARYLANGID(GetUserDefaultLangID())) + { + case LANG_CHINESE: + case LANG_JAPANESE: + case LANG_KOREAN: + break; + + default: + return; + } + + if (!GetObjectW(pDlgData->hLogoBitmap, sizeof(BITMAP), &bmLogo) || + !GetObjectW(pDlgData->hBarBitmap, sizeof(BITMAP), &bmBar)) + { + return; + } + + GetWindowRect(hwndBar, &rcBar); + MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcBar, 2); + dyLabel = bmLogo.bmHeight - rcBar.top; + + GetWindowRect(hwndLabel, &rcLabel); + MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rcLabel, 2); + cxLabel = rcLabel.right - rcLabel.left; + cyLabel = rcLabel.bottom - rcLabel.top; + + MoveWindow(hwndLogo, 0, 0, bmLogo.bmWidth, bmLogo.bmHeight, TRUE); + MoveWindow(hwndBar, 0, bmLogo.bmHeight, bmLogo.bmWidth, bmBar.bmHeight, TRUE); + MoveWindow(hwndLabel, rcLabel.left, rcLabel.top + dyLabel, cxLabel, cyLabel, TRUE); + + GetWindowRect(hwndDlg, &rcWnd); + xOld = rcWnd.left; + yOld = rcWnd.top; + cxOld = rcWnd.right - rcWnd.left; + cyOld = rcWnd.bottom - rcWnd.top; + + GetClientRect(hwndDlg, &rc); + SetRect(&rc, 0, 0, bmLogo.bmWidth, rc.bottom - rc.top); /* new client size */ + + style = (DWORD)GetWindowLongPtrW(hwndDlg, GWL_STYLE); + exstyle = (DWORD)GetWindowLongPtrW(hwndDlg, GWL_EXSTYLE); + AdjustWindowRectEx(&rc, style, FALSE, exstyle); + + cxNew = rc.right - rc.left; + cyNew = (rc.bottom - rc.top) + dyLabel; + xNew = xOld - (cxNew - cxOld) / 2; + yNew = yOld - (cyNew - cyOld) / 2; + MoveWindow(hwndDlg, xNew, yNew, cxNew, cyNew, TRUE); +} static INT_PTR CALLBACK StatusDialogProc( @@ -226,6 +289,8 @@ StatusDialogProc( pDlgData->hWndBarCtrl = GetDlgItem(hwndDlg, IDC_BAR); } } + + AdjustStatusMessageWindow(hwndDlg, pDlgData); return TRUE; } diff --git a/dll/win32/msgina/lang/ja-JP.rc b/dll/win32/msgina/lang/ja-JP.rc index 7b711b43951..65f8a78d4ea 100644 --- a/dll/win32/msgina/lang/ja-JP.rc +++ b/dll/win32/msgina/lang/ja-JP.rc @@ -1,13 +1,13 @@ LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT -IDD_STATUS DIALOGEX 0, 0, 236, 78 +IDD_STATUS DIALOGEX 0, 0, 275, 78 STYLE NOT WS_VISIBLE | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP CAPTION "お待ちください..." FONT 9, "MS UI Gothic", 400, 0, 1 BEGIN CONTROL IDI_ROSLOGO, IDC_ROSLOGO, "Static", SS_BITMAP, 0, 0, 275, 54 - CONTROL "", IDC_BAR, "Static", SS_OWNERDRAW, 0, 35, 275, 4 - LTEXT "", IDC_STATUS_MESSAGE, 7, 59, 229, 12, SS_WORDELLIPSIS + CONTROL "", IDC_BAR, "Static", SS_OWNERDRAW, 0, 44, 275, 4 + LTEXT "", IDC_STATUS_MESSAGE, 7, 59, 261, 12, SS_WORDELLIPSIS END IDD_WELCOME DIALOGEX 0, 0, 236, 78 -- 2.17.1