Skip to content

Commit

Permalink
Merge pull request #165 from end2endzone/feature-issue6 #6 #31
Browse files Browse the repository at this point in the history
Merge branch feature-issue6.
  • Loading branch information
end2endzone authored Aug 25, 2024
2 parents a4516fe + 94e1161 commit 5ffa505
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changes for 0.10.0

* Deprecated support for icons with negative resource id.
* Fixed issue #6 : (twice) Right-click on a directory with Windows Explorer in the left panel shows the menus twice.
* Fixed issue #31 : (twice) Error in logs for CContextMenu::GetCommandString()
* Fixed issue #109: Implement default and verbose logging.
* Fixed issue #150: ico icon (that do not specifically force index=0) are not working.
* Fixed issue #155: Drop support for loading icons from a resource id (icons with a negative index smaller than -1).
Expand Down
5 changes: 3 additions & 2 deletions src/shellextension/CContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
OBJECT_ENTRY_AUTO(CLSID_ShellAnything, CContextMenu)

static const GUID CLSID_UNDOCUMENTED_01 = { 0x924502a7, 0xcc8e, 0x4f60, { 0xae, 0x1f, 0xf7, 0x0c, 0x0a, 0x2b, 0x7a, 0x7c } };
HMENU CContextMenu::m_previousMenu = 0;

void CContextMenu::BuildSubMenuTree(HMENU hMenu, shellanything::Menu* menu, UINT& insert_pos, bool& next_menu_is_column)
{
Expand Down Expand Up @@ -333,7 +334,6 @@ CContextMenu::CContextMenu()
m_FirstCommandId = 0;
m_IsBackGround = false;
m_BuildMenuTreeCount = 0;
m_previousMenu = 0;
}

CContextMenu::~CContextMenu()
Expand Down Expand Up @@ -382,7 +382,8 @@ HRESULT STDMETHODCALLTYPE CContextMenu::QueryContextMenu(HMENU hMenu, UINT menu_
//Issue #6 - Right-click on a directory with Windows Explorer in the left panel shows the menus twice.
//Issue #31 - Error in logs for CContextMenu::GetCommandString().
//Using a static variable is a poor method for solving the issue but it is a "good enough" strategy.
SA_LOG(INFO) << "Skipped, QueryContextMenu() called twice and menu is already populated once.";
SA_LOG(INFO) << "Skipped, QueryContextMenu() called twice and menu is already populated once. "
"A call to QueryContextMenu() from another instance has already run and populated the menu.";
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); //nothing inserted
}

Expand Down
2 changes: 1 addition & 1 deletion src/shellextension/CContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ class ATL_NO_VTABLE CContextMenu :
int m_BuildMenuTreeCount; //number of times that BuildMenuTree() was called
shellanything::BitmapCache m_BitmapCache;
IconMap m_FileExtensionCache;
HMENU m_previousMenu;
static HMENU m_previousMenu; // issue #6. Field must be static
shellanything::SelectionContext m_Context;
};
23 changes: 18 additions & 5 deletions src/shellextension/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,25 @@ template <class T> class FlagDescriptor
const T& flag = flags[index].value;
const char* name = flags[index].name;

//if flag is set
if ((value & flag) == flag)
// Test special case where a flag has no bit set (flag == 0x00)
// The only time where it should be reported is when the value is also 0.
if (flag == 0)
{
if (!desc.empty())
desc.append("|");
desc.append(name);
if (flag == value)
{
desc = name;
break;
}
}
else
{
//if flag is set
if ((value & flag) == flag)
{
if (!desc.empty())
desc.append("|");
desc.append(name);
}
}

//next flag
Expand Down

0 comments on commit 5ffa505

Please sign in to comment.