Improve size calculation of value dialog

Fix #8443, close #9432
pull/9436/head
Udo Hoffmann 2021-01-21 11:45:10 +01:00 committed by Don HO
parent ce0012ab5c
commit 0004981ff7
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
1 changed files with 12 additions and 7 deletions

View File

@ -72,11 +72,16 @@ int ValueDlg::reSizeValueBox()
// convert screen coordonnees to client coordonnees
::ScreenToClient(_hSelf, &p);
int unit = w / (DEFAULT_NB_NUMBER + 2);
int extraSize = (_nbNumber-DEFAULT_NB_NUMBER)*unit;
::MoveWindow(hEdit, p.x, p.y, w + extraSize, h, FALSE);
return extraSize;
RECT rcText;
::SendMessage(hEdit, EM_GETRECT, 0, reinterpret_cast<LPARAM>(&rcText));
DWORD m = (DWORD)::SendMessage(hEdit, EM_GETMARGINS, 0, 0);
int margins = LOWORD(m) + HIWORD(m);
int textWidth = rcText.right - rcText.left;
int frameWidth = w - textWidth;
int newTextWidth = ((textWidth - margins) * _nbNumber / DEFAULT_NB_NUMBER) + margins + 1;
int newWidth = newTextWidth + frameWidth;
::MoveWindow(hEdit, p.x, p.y, newWidth, h, FALSE);
return newWidth - w;
}
INT_PTR CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
@ -89,9 +94,9 @@ INT_PTR CALLBACK ValueDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
::SetDlgItemInt(_hSelf, IDC_VALUE_EDIT, _defaultValue, FALSE);
RECT rc;
::GetClientRect(_hSelf, &rc);
::GetWindowRect(_hSelf, &rc);
int size = reSizeValueBox();
::MoveWindow(_hSelf, _p.x, _p.y, rc.right - rc.left + size, rc.bottom - rc.top + 30, TRUE);
::MoveWindow(_hSelf, _p.x, _p.y, rc.right - rc.left + size, rc.bottom - rc.top, TRUE);
return TRUE;
}