Skip to content

Commit

Permalink
Added option to single-expand any Win7 style item
Browse files Browse the repository at this point in the history
Expands the "display as a list of drives" option from This PC to work on
almost any item in the Windows 7 style. Incompatible items have a new
setting called ITEM_NODRIVES which blocks the option from appearing.
This PC still uses the original "list of drives" text, while other items
use "list of links" instead. Sorting has been updated to account for
this option by adding a property called bFolderLink which marks any
folder, even if it is not explicitly expandable.
  • Loading branch information
thisismy-github authored and Ibuprophen committed Aug 13, 2022
1 parent ef663d2 commit bb26cec
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Src/StartMenu/StartMenuDLL/CustomMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ CStdCommand7 g_StdCommands7[]={
{L"user_videos",0,NULL,L"$Menu.UserVideosTip",NULL,&FOLDERID_Videos},
{L"control_panel",0,L"$Menu.ControlPanel",L"$Menu.ControlPanelTip",NULL,&FOLDERID_ControlPanelFolder,NULL,StdMenuItem::MENU_TRACK},
{L"pc_settings",IDS_PCSETTINGS,L"$Menu.PCSettings",L"",L"%windir%\\ImmersiveControlPanel\\SystemSettings.exe,10",NULL,NULL,StdMenuItem::MENU_TRACK,CStdCommand7::ITEM_SINGLE},
{L"network_connections",0,NULL,L"$Menu.NetworkTip",NULL,&FOLDERID_ConnectionsFolder},
{L"network_connections",0,NULL,L"$Menu.NetworkTip",NULL,&FOLDERID_ConnectionsFolder,NULL,0,CStdCommand7::ITEM_NODRIVES},
{L"network",0,NULL,NULL,NULL,&FOLDERID_NetworkFolder,NULL,0,CStdCommand7::ITEM_SINGLE},
{L"printers",0,NULL,L"$Menu.PrintersTip",NULL,&FOLDERID_PrintersFolder},
{L"printers",0,NULL,L"$Menu.PrintersTip",NULL,&FOLDERID_PrintersFolder,NULL,0,CStdCommand7::ITEM_NODRIVES},
{L"fonts",0,NULL,NULL,NULL,&FOLDERID_Fonts},
{L"desktop",0,NULL,NULL,NULL,&FOLDERID_Desktop},
{L"admin",0,NULL,L"$Menu.AdminToolsTip",L"imageres.dll,114",&FOLDERID_CommonAdminTools,NULL,StdMenuItem::MENU_TRACK},
{L"startup",0,NULL,NULL,NULL,&FOLDERID_Startup,NULL,StdMenuItem::MENU_TRACK},
{L"admin",0,NULL,L"$Menu.AdminToolsTip",L"imageres.dll,114",&FOLDERID_CommonAdminTools,NULL,StdMenuItem::MENU_TRACK,CStdCommand7::ITEM_NODRIVES},
{L"startup",0,NULL,NULL,NULL,&FOLDERID_Startup,NULL,StdMenuItem::MENU_TRACK,CStdCommand7::ITEM_NODRIVES},
{L"downloads",0,NULL,L"$Menu.DownloadTip",NULL,&FOLDERID_Downloads},
{L"games",0,NULL,L"$Menu.GamesTip",NULL,&FOLDERID_Games,NULL,StdMenuItem::MENU_TRACK},
{L"links",0,NULL,NULL,NULL,&FOLDERID_Links},
Expand All @@ -112,7 +112,7 @@ CStdCommand7 g_StdCommands7[]={
{L"lib_videos",IDS_LIB_VIDEOS_ITEM,NULL,L"$Menu.VideosLibTip",NULL,&FOLDERID_VideosLibrary},
{L"lib_tv",IDS_LIB_TV_ITEM,NULL,L"$Menu.RecordingsLibTip",NULL,&FOLDERID_RecordedTVLibrary},
{L"homegroup",0,NULL,L"$Menu.HomegroupTip",NULL,&FOLDERID_HomeGroup,NULL,0,CStdCommand7::ITEM_SINGLE},
{L"devices",0,NULL,NULL,NULL,NULL,L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{A8A91A66-3A7D-4424-8D24-04E180695C7A}"},
{L"devices",0,NULL,NULL,NULL,NULL,L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{A8A91A66-3A7D-4424-8D24-04E180695C7A}",0,CStdCommand7::ITEM_NODRIVES},
{L"defaults",0,NULL,NULL,NULL,NULL,L"::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0\\::{17CD9488-1228-4B2F-88CE-4298E93E0966}",0,CStdCommand7::ITEM_SINGLE},
{L"apps",IDS_METRO_APPS,L"$Menu.Apps",NULL,L",2",NULL,NULL,StdMenuItem::MENU_TRACK,CStdCommand7::ITEM_FOLDER},

Expand Down
1 change: 1 addition & 0 deletions Src/StartMenu/StartMenuDLL/CustomMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct CStdCommand7
ITEM_SINGLE=1, // this item never has sub-menu
ITEM_FOLDER=2, // this item always has sub-menu
ITEM_COMPUTER=4, // this item can be expanded only one level
ITEM_NODRIVES=8, // this item can never be expanded only one level
};
const wchar_t *command;
int nameID;
Expand Down
2 changes: 1 addition & 1 deletion Src/StartMenu/StartMenuDLL/DragDrop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ HRESULT STDMETHODCALLTYPE CMenuContainer::Drop( IDataObject *pDataObj, DWORD grf
else if (i<before)
skip++;
}
SortMenuItem ins(L"",FNV_HASH0,false,false,folderIndex*2,0);
SortMenuItem ins(L"",FNV_HASH0,false,false,false,folderIndex*2,0);
items.insert(items.begin()+(before-skip),ins);
SaveItemOrder(items);
}
Expand Down
7 changes: 4 additions & 3 deletions Src/StartMenu/StartMenuDLL/MenuContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ void CMenuContainer::AddFirstFolder( IShellItem *pFolder, std::vector<MenuItem>

if (bLibrary) flags&=~SFGAO_STREAM;
item.bLink=(flags&SFGAO_LINK)!=0;
item.bFolder=(!(options&CONTAINER_CONTROLPANEL) && !(options&CONTAINER_NOSUBFOLDERS) && (flags&SFGAO_FOLDER) && (!(flags&(SFGAO_STREAM|SFGAO_LINK)) || (s_bExpandLinks && item.bLink)));
item.bFolderLink=(flags&SFGAO_FOLDER && (!(flags&(SFGAO_STREAM|SFGAO_LINK)) || (s_bExpandLinks && item.bLink)));
item.bFolder=(!(options&CONTAINER_CONTROLPANEL) && !(options&CONTAINER_NOSUBFOLDERS) && item.bFolderLink);
{
CItemManager::RWLock lock(&g_ItemManager,false,CItemManager::RWLOCK_ITEMS);
if (item.pItemInfo->IsMetroLink())
Expand Down Expand Up @@ -2505,9 +2506,9 @@ void CMenuContainer::InitItems( void )
m_Items.resize(MAX_MENU_ITEMS);
}

if (m_Options&CONTAINER_CONTROLPANEL)
if (m_Options&CONTAINER_CONTROLPANEL && !(m_Options&CONTAINER_NOSUBFOLDERS))
{
// expand Administrative Tools. must be done after the sorting because we don't want the folder to jump to the top
// expand Administrative Tools when displaying as a menu. must be done after the sorting because we don't want the folder to jump to the top
unsigned int AdminToolsHash=CalcFNVHash(L"::{D20EA4E1-3957-11D2-A40B-0C5020524153}");
for (std::vector<MenuItem>::iterator it=m_Items.begin();it!=m_Items.end();++it)
if (it->nameHash==AdminToolsHash)
Expand Down
16 changes: 9 additions & 7 deletions Src/StartMenu/StartMenuDLL/MenuContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
drawType=MenuSkin::COLUMN1_ITEM;
column=row=0;
memset(&itemRect,0,sizeof(itemRect));
bFolder=bLink=bPrograms=bAlignBottom=bBreak=bInline=bInlineFirst=bInlineLast=bSplit=bHasJumpList=bMetroLink=bMetroApp=bBlankSeparator=bNew=bStartScreen=bCustomAccelerator=false;
bFolder=bLink=bFolderLink=bPrograms=bAlignBottom=bBreak=bInline=bInlineFirst=bInlineLast=bSplit=bHasJumpList=bMetroLink=bMetroApp=bBlankSeparator=bNew=bStartScreen=bCustomAccelerator=false;
priority=0;
pItem1=pItem2=NULL;
mfuHash=0;
Expand All @@ -477,6 +477,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
RECT itemRect;
bool bFolder:1; // this is a folder - draw arrow
bool bLink:1; // this is a link (if a link to a folder is expanded it is always single-column)
bool bFolderLink:1; // this is a folder that is not explicitly expandable - used for sorting the list-of-links style
bool bPrograms:1; // this item is part of the Start Menu folder hierarchy
bool bAlignBottom:1; // two-column menu: this item is aligned to the bottom
bool bBreak:1; // two-column menu: this item starts the second column
Expand Down Expand Up @@ -512,8 +513,8 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
if (priority>item.priority) return false;
if (row<item.row) return true;
if (row>item.row) return false;
if ((bFolder && !bHasJumpList) && !(item.bFolder && !item.bHasJumpList)) return true;
if (!(bFolder && !bHasJumpList) && (item.bFolder && !item.bHasJumpList)) return false;
if (((bFolder || bFolderLink) && !bHasJumpList) && !((item.bFolder || item.bFolderLink) && !item.bHasJumpList)) return true;
if (!((bFolder || bFolderLink) && !bHasJumpList) && ((item.bFolder || item.bFolderLink) && !item.bHasJumpList)) return false;
if (drive && !item.drive) return true;
if (!drive && item.drive) return false;
if (drive && item.drive) return drive<item.drive;
Expand Down Expand Up @@ -578,18 +579,19 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
CString name;
unsigned int nameHash;
bool bFolder;
bool bFolderLink;
bool bHasJumpList;
char priority;
char drive;

SortMenuItem( const CString &_name, unsigned _nameHash, bool _bFolder, bool _bHasJumpList, char _priority ,char _drive) { name=_name; nameHash=_nameHash; bFolder=_bFolder; bHasJumpList=_bHasJumpList; priority=_priority; drive=_drive; }
SortMenuItem( const MenuItem &item ) { name=item.name; nameHash=item.nameHash; bFolder=item.bFolder; bHasJumpList=item.bHasJumpList; priority=item.priority; drive=item.drive; }
SortMenuItem( const CString &_name, unsigned _nameHash, bool _bFolder, bool _bFolderLink, bool _bHasJumpList, char _priority ,char _drive) { name=_name; nameHash=_nameHash; bFolder=_bFolder; bFolderLink=_bFolderLink; bHasJumpList=_bHasJumpList; priority=_priority; drive=_drive; }
SortMenuItem( const MenuItem &item ) { name=item.name; nameHash=item.nameHash; bFolder=item.bFolder; bFolderLink=item.bFolderLink; bHasJumpList=item.bHasJumpList; priority=item.priority; drive=item.drive; }
bool operator<( const SortMenuItem &x ) const
{
if (priority<x.priority) return true;
if (priority>x.priority) return false;
if ((bFolder && !bHasJumpList) && !(x.bFolder && !x.bHasJumpList)) return true;
if (!(bFolder && !bHasJumpList) && (x.bFolder && !x.bHasJumpList)) return false;
if (((bFolder || bFolderLink) && !bHasJumpList) && !((x.bFolder || x.bFolderLink) && !x.bHasJumpList)) return true;
if (!((bFolder || bFolderLink) && !bHasJumpList) && ((x.bFolder || x.bFolderLink) && !x.bHasJumpList)) return false;
if (drive && !x.drive) return true;
if (!drive && x.drive) return false;
if (drive && x.drive) return drive<x.drive;
Expand Down
16 changes: 12 additions & 4 deletions Src/StartMenu/StartMenuDLL/SettingsUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2725,8 +2725,11 @@ void CCustomMenuDlg7::CItemList::UpdateItem( int index )
str=LoadStringEx(IDS_ITEM_SHOW2);
else if ((menuItem.settings&StdMenuItem::MENU_NOEXPAND) && !(g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_FOLDER))
str=LoadStringEx(IDS_ITEM_SHOW);
else if ((menuItem.settings&StdMenuItem::MENU_SINGLE_EXPAND) && (g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_COMPUTER))
str=LoadStringEx(IDS_ITEM_DRIVES);
else if ((menuItem.settings&StdMenuItem::MENU_SINGLE_EXPAND) && !(g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_NODRIVES))
if (g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_COMPUTER)
str=LoadStringEx(IDS_ITEM_DRIVES);
else
str=LoadStringEx(IDS_ITEM_LINKS);
else
str=LoadStringEx(IDS_ITEM_MENU);
ListView_SetItemText(m_hWnd,index,2,(wchar_t*)(const wchar_t*)str);
Expand Down Expand Up @@ -3160,7 +3163,7 @@ LRESULT CCustomMenuDlg7::CItemList::OnSelEndOk( WORD wNotifyCode, WORD wID, HWND
menuItem.settings|=StdMenuItem::MENU_ITEM_DISABLED;
else if (sel==1 && !(g_StdCommands7[menuItem.stdItemIndex].flags&(CStdCommand7::ITEM_SINGLE|CStdCommand7::ITEM_FOLDER)))
menuItem.settings|=StdMenuItem::MENU_NOEXPAND;
else if (sel==3 && (g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_COMPUTER))
else if (sel==3 && !(g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_NODRIVES))
menuItem.settings|=StdMenuItem::MENU_SINGLE_EXPAND;
}
UpdateItem(m_Line);
Expand Down Expand Up @@ -3307,12 +3310,17 @@ void CCustomMenuDlg7::CItemList::CreateCombo( int line, int column )
str=LoadStringEx(IDS_ITEM_DRIVES);
m_Combo.SendMessage(CB_ADDSTRING,0,(LPARAM)(const wchar_t*)str);
}
else if (!(g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_NODRIVES))
{
str=LoadStringEx(IDS_ITEM_LINKS);
m_Combo.SendMessage(CB_ADDSTRING,0,(LPARAM)(const wchar_t*)str);
}
}
if (menuItem.settings&StdMenuItem::MENU_ITEM_DISABLED)
m_Combo.SendMessage(CB_SETCURSEL,0);
else if ((g_StdCommands7[menuItem.stdItemIndex].flags&(CStdCommand7::ITEM_SINGLE|CStdCommand7::ITEM_FOLDER)) || (menuItem.settings&StdMenuItem::MENU_NOEXPAND))
m_Combo.SendMessage(CB_SETCURSEL,1);
else if ((g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_COMPUTER) && (menuItem.settings&StdMenuItem::MENU_SINGLE_EXPAND))
else if (!(g_StdCommands7[menuItem.stdItemIndex].flags&CStdCommand7::ITEM_NODRIVES) && (menuItem.settings&StdMenuItem::MENU_SINGLE_EXPAND))
m_Combo.SendMessage(CB_SETCURSEL,3);
else
m_Combo.SendMessage(CB_SETCURSEL,2);
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/StartMenuDLL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,8 @@ BEGIN
IDS_OPEN_CMD_TIP "The action will run a user-defined command"
IDS_OPEN_CMD_TEXT "Command to run"
IDS_OPEN_CMD_TEXT_TIP "Enter the command to run when you use this control"
IDS_ITEM_LINKS "Display as a list of links"
IDS_ITEM_LINKS_TIP "This item will appear as a sub-menu showing only its top-level contents"
END

#endif // English (U.S.) resources
Expand Down
2 changes: 2 additions & 0 deletions Src/StartMenu/StartMenuDLL/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@
#define IDS_OPEN_CMD_TIP 3677
#define IDS_OPEN_CMD_TEXT 3678
#define IDS_OPEN_CMD_TEXT_TIP 3679
#define IDS_ITEM_LINKS 3680
#define IDS_ITEM_LINKS_TIP 3681
#define IDS_STRING7001 7001
#define IDS_STRING7002 7002
#define IDS_STRING7003 7003
Expand Down

0 comments on commit bb26cec

Please sign in to comment.