Fix Doc Switcher bottom cut off regression

Fix #13053, close #13054
This commit is contained in:
ozone10 2023-02-05 12:09:06 +01:00 committed by Don Ho
parent 43d9f0d665
commit 296a168b3f

View File

@ -27,7 +27,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem
_currentIndex = index2set; _currentIndex = index2set;
INITCOMMONCONTROLSEX icex; INITCOMMONCONTROLSEX icex{};
// Ensure that the common control DLL is loaded. // Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
@ -65,7 +65,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem
ListView_SetExtendedListViewStyle(_hSelf, exStyle); ListView_SetExtendedListViewStyle(_hSelf, exStyle);
LVCOLUMN lvColumn; LVCOLUMN lvColumn{};
lvColumn.mask = LVCF_WIDTH; lvColumn.mask = LVCF_WIDTH;
lvColumn.cx = 500; lvColumn.cx = 500;
@ -91,18 +91,19 @@ void TaskList::destroy()
RECT TaskList::adjustSize() RECT TaskList::adjustSize()
{ {
RECT rc; RECT rc{};
ListView_GetItemRect(_hSelf, 0, &rc, LVIR_ICON); ListView_GetItemRect(_hSelf, 0, &rc, LVIR_ICON);
const int imgWidth = rc.right - rc.left; const int imgWidth = rc.right - rc.left;
const int aSpaceWidth = ListView_GetStringWidth(_hSelf, TEXT(" ")); const int aSpaceWidth = ListView_GetStringWidth(_hSelf, TEXT(" "));
const int leftMarge = ::GetSystemMetrics(SM_CXFRAME) * 2 + aSpaceWidth * 4; const int paddedBorder = ::GetSystemMetrics(SM_CXPADDEDBORDER);
const int leftMarge = (::GetSystemMetrics(SM_CXFRAME) + paddedBorder) * 2 + aSpaceWidth * 4;
// Temporary set "selected" font to get the worst case widths // Temporary set "selected" font to get the worst case widths
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFontSelected), 0); ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFontSelected), 0);
int maxwidth = -1; int maxwidth = -1;
_rc = { 0, 0, 0, 0 }; _rc = { 0, 0, 0, 0 };
TCHAR buf[MAX_PATH]; TCHAR buf[MAX_PATH] = { '\0' };
for (int i = 0 ; i < _nbItem ; ++i) for (int i = 0 ; i < _nbItem ; ++i)
{ {
ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH); ListView_GetItemText(_hSelf, i, 0, buf, MAX_PATH);
@ -117,14 +118,15 @@ RECT TaskList::adjustSize()
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0); ::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
//if the tasklist exceeds the height of the display, leave some space at the bottom //if the tasklist exceeds the height of the display, leave some space at the bottom
if (_rc.bottom > ::GetSystemMetrics(SM_CYSCREEN) - 120) const LONG maxHeight = ::GetSystemMetrics(SM_CYSCREEN) - 120L;
if (_rc.bottom > maxHeight)
{ {
_rc.bottom = ::GetSystemMetrics(SM_CYSCREEN) - 120; _rc.bottom = maxHeight;
} }
reSizeTo(_rc); reSizeToWH(_rc);
// Task List's border is 1px smaller than ::GetSystemMetrics(SM_CYFRAME) returns // Task List's border is 1px smaller than ::GetSystemMetrics(SM_CYFRAME) returns
_rc.bottom += (::GetSystemMetrics(SM_CYFRAME) - 1) * 2; _rc.bottom += (::GetSystemMetrics(SM_CYFRAME) + paddedBorder - 1) * 2;
return _rc; return _rc;
} }