From fae6fad568dc5fa3f6eb53aa9317ea2de430d97a Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 14 Oct 2011 17:58:44 +0200 Subject: [PATCH] Fixed issue #916: Fixed wrong contextmenu icon display position with installed TSVN 1.7 This reverts commit 2fa11ac2a8a531c1c615e4e2633a8e557c811ad4, but extends it. Based on http://code.google.com/p/tortoisesvn/source/detail?r=20656. Signed-off-by: Sven Strickroth --- src/TortoiseShell/ContextMenu.cpp | 19 +++++++++++++++---- src/TortoiseShell/ShellExt.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/TortoiseShell/ContextMenu.cpp b/src/TortoiseShell/ContextMenu.cpp index 39884be80..9d26b6dc9 100644 --- a/src/TortoiseShell/ContextMenu.cpp +++ b/src/TortoiseShell/ContextMenu.cpp @@ -823,6 +823,8 @@ STDMETHODIMP CShellExt::QueryDropContext(UINT uFlags, UINT idCmdFirst, HMENU hMe if (idCmd != idCmdFirst) InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); + TweakMenu(hMenu); + return ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(idCmd - idCmdFirst))); } @@ -1191,10 +1193,20 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, //separator after InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); idCmd++; + TweakMenu(hMenu); + //return number of menu items added return ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(idCmd - idCmdFirst))); } +void CShellExt::TweakMenu(HMENU hMenu) +{ + MENUINFO MenuInfo = {}; + MenuInfo.cbSize = sizeof(MenuInfo); + MenuInfo.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS; + MenuInfo.dwStyle = MNS_CHECKORBMP; + SetMenuInfo(hMenu, &MenuInfo); +} // This is called when you invoke a command on the menu: STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) @@ -2073,9 +2085,8 @@ STDMETHODIMP CShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, MEASUREITEMSTRUCT* lpmis = (MEASUREITEMSTRUCT*)lParam; if (lpmis==NULL||lpmis->CtlType!=ODT_MENU) break; - lpmis->itemWidth += 2; - if (lpmis->itemHeight < 16) - lpmis->itemHeight = 16; + lpmis->itemWidth = 16; + lpmis->itemHeight = 16; *pResult = TRUE; } break; @@ -2092,7 +2103,7 @@ STDMETHODIMP CShellExt::HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, if (hIcon == NULL) return S_OK; DrawIconEx(lpdis->hDC, - lpdis->rcItem.left < 16 ? lpdis->rcItem.left : lpdis->rcItem.left - 16, + lpdis->rcItem.left, lpdis->rcItem.top + (lpdis->rcItem.bottom - lpdis->rcItem.top - 16) / 2, hIcon, 16, 16, 0, NULL, DI_NORMAL); diff --git a/src/TortoiseShell/ShellExt.h b/src/TortoiseShell/ShellExt.h index 7cbf034bf..af79489c9 100644 --- a/src/TortoiseShell/ShellExt.h +++ b/src/TortoiseShell/ShellExt.h @@ -125,6 +125,7 @@ private: LPCTSTR GetMenuTextFromResource(int id); void GetColumnStatus(const TCHAR * path, BOOL bIsDir); void GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci, UINT characterCount, UINT title, UINT description); + void TweakMenu(HMENU menu); HBITMAP IconToBitmap(UINT uIcon); STDMETHODIMP QueryDropContext(UINT uFlags, UINT idCmdFirst, HMENU hMenu, UINT &indexMenu); bool IsIllegalFolder(std::wstring folder, int * cslidarray); -- 2.11.4.GIT