From 457208a39f6de8d70593a74e8f09c82b4998c871 Mon Sep 17 00:00:00 2001 From: St0RM53 Date: Sat, 21 Nov 2026 01:07:21 +0200 Subject: [PATCH 1/2] Limit search results per category in Win7-style menus The SearchResults/SearchResultsMax settings were only honored by the classic menu styles; Win7-style menus always divided the available height equally between categories. Expose both settings in Win7 style and clamp the height-based count so both styles behave consistently. Note: with the default of 5, tall menus that previously showed more items per category will now show fewer. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 4 ++++ Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 3337b66a8..18855e5f3 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -2869,6 +2869,10 @@ bool CMenuContainer::InitSearchItems( void ) count=(h-sepHeight)/itemHeight; if (categoryHash!=m_SearchCategoryHash && count>maxCount) count=maxCount; + // limit the number of results per category (same setting as the non-Win7 styles) + int limit=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); + if (count>limit) + count=limit; } else { diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index af9376103..d7f573c55 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -4382,8 +4382,8 @@ CSetting g_Settings[]={ {L"SearchHint",CSetting::TYPE_BOOL,IDS_SEARCH_HINT,IDS_SEARCH_HINT_TIP,0,0,L"SearchBox"}, {L"SearchHintText",CSetting::TYPE_STRING,IDS_NEW_SEARCH_HINT,IDS_NEW_SEARCH_HINT_TIP,L"",0,L"#SearchHint",L"SearchHint"}, {L"SearchTrack",CSetting::TYPE_BOOL,IDS_SEARCH_TRACK,IDS_SEARCH_TRACK_TIP,1,0,L"SearchBox"}, - {L"SearchResults",CSetting::TYPE_INT,IDS_SEARCH_MAX2,IDS_SEARCH_MAX_TIP2,5,CSetting::FLAG_MENU_CLASSIC_BOTH,L"SearchBox"}, - {L"SearchResultsMax",CSetting::TYPE_INT,IDS_SEARCH_MAX3,IDS_SEARCH_MAX_TIP3,20,CSetting::FLAG_MENU_CLASSIC_BOTH,L"SearchBox"}, + {L"SearchResults",CSetting::TYPE_INT,IDS_SEARCH_MAX2,IDS_SEARCH_MAX_TIP2,5,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, + {L"SearchResultsMax",CSetting::TYPE_INT,IDS_SEARCH_MAX3,IDS_SEARCH_MAX_TIP3,20,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, {L"SearchAutoComplete",CSetting::TYPE_BOOL,IDS_SEARCH_AUTO,IDS_SEARCH_AUTO_TIP,1,0,L"SearchBox"}, {L"SearchPrograms",CSetting::TYPE_BOOL,IDS_SEARCH_PROGRAMS,IDS_SEARCH_PROGRAMS_TIP,1,0,L"SearchBox"}, {L"SearchPath",CSetting::TYPE_BOOL,IDS_SEARCH_PATH,IDS_SEARCH_PATH_TIP,1,0,L"#SearchPrograms",L"SearchPrograms"}, From d72fa618a735b4c39231f3faa52c2495cd00d7f6 Mon Sep 17 00:00:00 2001 From: St0RM53 Date: Sat, 21 Nov 2026 01:07:22 +0200 Subject: [PATCH 2/2] Add "Prioritize results per category" option with a scrollable list New SearchResultsPriority option (Win7 style): when enabled, the configured per-category counts are always used instead of dividing the available space, and the search list becomes scrollable when the results don't fit, reusing the existing search scroll machinery. The scroll offset is now computed from the actual row heights, so mixed-height lists (category headers are taller than items) scroll correctly. --- Src/StartMenu/StartMenuDLL/MenuContainer.cpp | 82 +++++++++++++++++--- Src/StartMenu/StartMenuDLL/MenuContainer.h | 1 + Src/StartMenu/StartMenuDLL/MenuPaint.cpp | 2 +- Src/StartMenu/StartMenuDLL/SettingsUI.cpp | 1 + Src/StartMenu/StartMenuDLL/StartMenuDLL.rc | 2 + Src/StartMenu/StartMenuDLL/resource.h | 3 + 6 files changed, 78 insertions(+), 13 deletions(-) diff --git a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp index 18855e5f3..43720ff65 100644 --- a/Src/StartMenu/StartMenuDLL/MenuContainer.cpp +++ b/Src/StartMenu/StartMenuDLL/MenuContainer.cpp @@ -2763,6 +2763,7 @@ bool CMenuContainer::InitSearchItems( void ) std::vector counts; int sepHeight=0, itemHeight=0, maxHeight=0, reservedHeight=0; int maxCount=0; + bool bPrioritySearch=(s_bWin7Style && GetSettingBool(L"SearchResultsPriority")); if (s_bWin7Style) { sepHeight=s_Skin.ItemSettings[s_Skin.More_bitmap_Size.cx?MenuSkin::LIST_SEPARATOR_SPLIT:MenuSkin::LIST_SEPARATOR].itemHeight; @@ -2787,6 +2788,8 @@ bool CMenuContainer::InitSearchItems( void ) } if (s_bWin7Style) { + if (!bPrioritySearch) + { // calculate the allowed counts per category int selectedCount=0; if (!s_SearchResults.programs.empty()) @@ -2845,9 +2848,12 @@ bool CMenuContainer::InitSearchItems( void ) if (reservedHeight>maxHeight) reservedHeight=maxHeight; maxHeight-=reservedHeight; } + } } // add categories + int resultsHeight=maxHeight; + int fitRows=0, fitH=0; // rows that fit in the results area (for the scrollbar page size) std::list::const_iterator it=s_SearchResults.indexed.begin(); for (size_t idx=0;idxmaxCount) - count=maxCount; - // limit the number of results per category (same setting as the non-Win7 styles) - int limit=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); - if (count>limit) - count=limit; + if (bPrioritySearch) + { + // always show the configured number of results per category, + // the list is made scrollable to fit the extra items + count=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); + } + else + { + int h=(categoryHash==m_SearchCategoryHash?reservedHeight:maxHeight); + count=(h-sepHeight)/itemHeight; + if (categoryHash!=m_SearchCategoryHash && count>maxCount) + count=maxCount; + // limit the number of results per category (same setting as the non-Win7 styles) + int limit=GetSettingInt(categoryHash==m_SearchCategoryHash?L"SearchResultsMax":L"SearchResults"); + if (count>limit) + count=limit; + } } else { @@ -2961,11 +2976,37 @@ bool CMenuContainer::InitSearchItems( void ) { count=AddSearchItems(items,name,categoryHash,originalCount); } - if (s_bWin7Style && categoryHash!=m_SearchCategoryHash && count>0) - maxHeight-=sepHeight+count*itemHeight; + if (s_bWin7Style && count>0) + { + if (bPrioritySearch) + { + // count how many rows fit in the visible area (headers are taller than items) + for (int r=0;r<1+count && fitH0 && m_SearchScrollCount==0) + { + // enable scrolling when the prioritized results don't fit + int total=(int)m_Items.size()-m_OriginalCount; + if (total>fitRows) + { + m_SearchScrollCount=total; + m_SearchScrollHeight=fitRows; + } + } UpdateAccelerators(m_OriginalCount,(int)m_Items.size()); MenuItem &item=m_Items[m_SearchIndex-m_SearchItemCount+1]; if (s_SearchResults.bSearching) @@ -4510,6 +4551,23 @@ HRESULT __stdcall CMenuContainer::ReleaseAccessible( ComCallData *pData ) return CoDisconnectContext(INFINITE); } +// Returns the pixel offset the scrollable search list is shifted by. +// The scroll position is in rows, but the rows have different heights +// (category headers are taller), so the offset is the sum of the heights +// of the rows scrolled out of view. +int CMenuContainer::SearchScrollOffset( void ) const +{ + if (m_SearchScrollPos<=0) + return 0; + int end=m_OriginalCount+m_SearchScrollPos; + if (end>(int)m_Items.size()) + end=(int)m_Items.size(); + int offset=0; + for (int i=m_OriginalCount;i=0 && index<(int)m_Items.size()) @@ -4525,7 +4583,7 @@ bool CMenuContainer::GetItemRect( int index, RECT &rc ) } if (m_SearchScrollCount>m_SearchScrollHeight && index>=m_OriginalCount) { - OffsetRect(&rc,0,-m_SearchScrollPos*(rc.bottom-rc.top)); + OffsetRect(&rc,0,-SearchScrollOffset()); } } return true; @@ -4553,7 +4611,7 @@ int CMenuContainer::HitTest( const POINT &pt, bool *bArrow, bool bDrop ) } else if (m_SearchScrollCount>m_SearchScrollHeight && i>=m_OriginalCount) { - OffsetRect(&rc,0,-m_SearchScrollPos*(rc.bottom-rc.top)); + OffsetRect(&rc,0,-SearchScrollOffset()); } else if (bDrop && m_bTwoColumns && i=m_SearchScrollPos+m_SearchScrollHeight) continue; - OffsetRect(&itemRect,0,-m_SearchScrollPos*(itemRect.bottom-itemRect.top)); + OffsetRect(&itemRect,0,-SearchScrollOffset()); } { RECT q; diff --git a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp index d7f573c55..84ff2f5ab 100644 --- a/Src/StartMenu/StartMenuDLL/SettingsUI.cpp +++ b/Src/StartMenu/StartMenuDLL/SettingsUI.cpp @@ -4384,6 +4384,7 @@ CSetting g_Settings[]={ {L"SearchTrack",CSetting::TYPE_BOOL,IDS_SEARCH_TRACK,IDS_SEARCH_TRACK_TIP,1,0,L"SearchBox"}, {L"SearchResults",CSetting::TYPE_INT,IDS_SEARCH_MAX2,IDS_SEARCH_MAX_TIP2,5,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, {L"SearchResultsMax",CSetting::TYPE_INT,IDS_SEARCH_MAX3,IDS_SEARCH_MAX_TIP3,20,CSetting::FLAG_MENU_CLASSIC_BOTH|CSetting::FLAG_MENU_WIN7,L"SearchBox"}, + {L"SearchResultsPriority",CSetting::TYPE_BOOL,IDS_SEARCH_PRIORITY,IDS_SEARCH_PRIORITY_TIP,0,CSetting::FLAG_MENU_WIN7,L"SearchBox"}, {L"SearchAutoComplete",CSetting::TYPE_BOOL,IDS_SEARCH_AUTO,IDS_SEARCH_AUTO_TIP,1,0,L"SearchBox"}, {L"SearchPrograms",CSetting::TYPE_BOOL,IDS_SEARCH_PROGRAMS,IDS_SEARCH_PROGRAMS_TIP,1,0,L"SearchBox"}, {L"SearchPath",CSetting::TYPE_BOOL,IDS_SEARCH_PATH,IDS_SEARCH_PATH_TIP,1,0,L"#SearchPrograms",L"SearchPrograms"}, diff --git a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc index d65ffce32..2e0cb8875 100644 --- a/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc +++ b/Src/StartMenu/StartMenuDLL/StartMenuDLL.rc @@ -1045,6 +1045,8 @@ BEGIN IDS_SEARCH_MAX_TIP2 "Limit the number of results shown per category" IDS_SEARCH_MAX3 "Results per maximized category" IDS_SEARCH_MAX_TIP3 "Limit the number of results shown for the maximized category" + IDS_SEARCH_PRIORITY "Prioritize results per category" + IDS_SEARCH_PRIORITY_TIP "Always show the specified number of results per category instead of dividing the available space equally. The search list becomes scrollable when the results don't fit" IDS_SHOW_APPS "Show Metro apps" IDS_SHOW_APPS_TIP "When this is checked, the programs tree will include a folder for the Metro apps" IDS_FOLDERS_FIRST "Show folders first" diff --git a/Src/StartMenu/StartMenuDLL/resource.h b/Src/StartMenu/StartMenuDLL/resource.h index 81acb7478..8cc0ecf0f 100644 --- a/Src/StartMenu/StartMenuDLL/resource.h +++ b/Src/StartMenu/StartMenuDLL/resource.h @@ -846,6 +846,9 @@ #define IDS_STRING7110 7110 #define IDS_STRING7111 7111 +#define IDS_SEARCH_PRIORITY 3297 +#define IDS_SEARCH_PRIORITY_TIP 3298 + // Next default values for new objects // #ifdef APSTUDIO_INVOKED