Improve size calculation of value dialog

Fix #8443, close #9432
This commit is contained in:
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

View File

@ -72,11 +72,16 @@ int ValueDlg::reSizeValueBox()
// convert screen coordonnees to client coordonnees // convert screen coordonnees to client coordonnees
::ScreenToClient(_hSelf, &p); ::ScreenToClient(_hSelf, &p);
int unit = w / (DEFAULT_NB_NUMBER + 2); RECT rcText;
int extraSize = (_nbNumber-DEFAULT_NB_NUMBER)*unit; ::SendMessage(hEdit, EM_GETRECT, 0, reinterpret_cast<LPARAM>(&rcText));
::MoveWindow(hEdit, p.x, p.y, w + extraSize, h, FALSE); DWORD m = (DWORD)::SendMessage(hEdit, EM_GETMARGINS, 0, 0);
int margins = LOWORD(m) + HIWORD(m);
return extraSize; 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) 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); ::SetDlgItemInt(_hSelf, IDC_VALUE_EDIT, _defaultValue, FALSE);
RECT rc; RECT rc;
::GetClientRect(_hSelf, &rc); ::GetWindowRect(_hSelf, &rc);
int size = reSizeValueBox(); 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; return TRUE;
} }