ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2014
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
18 participants
373 discussions
Start a n
N
ew thread
[akhaldi] 65285: [SHELL32] * Another partial sync of shlmenu.c with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 6 13:04:41 2014 New Revision: 65285 URL:
http://svn.reactos.org/svn/reactos?rev=65285&view=rev
Log: [SHELL32] * Another partial sync of shlmenu.c with Wine 1.7.27. CORE-8540 Modified: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c Modified: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c [iso-8859-1] Thu Nov 6 13:04:41 2014 @@ -33,8 +33,6 @@ #include "pidl.h" #include "shell32_main.h" -WINE_DEFAULT_DEBUG_CHANNEL(shellmenu); - #ifdef FM_SEPARATOR #undef FM_SEPARATOR #endif @@ -71,6 +69,8 @@ #define CCH_MAXITEMTEXT 256 +WINE_DEFAULT_DEBUG_CHANNEL(shell); + static LPFMINFO FM_GetMenuInfo(HMENU hmenu) { MENUINFO MenuInfo; @@ -127,9 +127,7 @@ * */ static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) -{ - IShellFolder *lpsf; - IShellFolder *lpsf2; +{ IShellFolder *lpsf, *lpsf2; ULONG ulItemAttr = SFGAO_FOLDER; UINT uID, uEnumFlags; LPFNFMCALLBACK lpfnCallback; @@ -173,7 +171,7 @@ { if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2))) { - IEnumIDList *lpe; + IEnumIDList *lpe = NULL; if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe ))) { @@ -194,7 +192,7 @@ MENUINFO MenuInfo; HMENU hMenuPopup = CreatePopupMenu(); - lpFmMi = (LPFMINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); + lpFmMi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); lpFmMi->pidl = ILCombine(pidl, pidlTemp); lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; @@ -224,8 +222,11 @@ NumberOfItems++; } + IEnumIDList_Release (lpe); } + IShellFolder_Release(lpsf2); } + IShellFolder_Release(lpsf); } if ( GetMenuItemCount (hmenu) == 0 ) @@ -262,7 +263,7 @@ TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); - menudata = (LPFMINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); + menudata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); menudata->crBorderColor = crBorderColor; menudata->nBorderWidth = nBorderWidth; menudata->hBorderBmp = hBorderBmp; @@ -326,8 +327,8 @@ if (lpText != FM_SEPARATOR) { int len = strlenW (lpText); - myItem = (LPFMITEM)SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR)); - wcscpy (myItem->szItemText, lpText); + myItem = SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR)); + strcpyW (myItem->szItemText, lpText); myItem->cchItemText = len; myItem->iIconIndex = icon; myItem->hMenu = hMenu; @@ -378,7 +379,7 @@ /**********************************************************************/ -EXTERN_C BOOL WINAPI FileMenu_AppendItemAW( +BOOL WINAPI FileMenu_AppendItemAW( HMENU hMenu, LPCVOID lpText, UINT uID, @@ -391,13 +392,13 @@ if (!lpText) return FALSE; if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR) - ret = FileMenu_AppendItemW(hMenu, (LPWSTR)lpText, uID, icon, hMenuPopup, nItemHeight); + ret = FileMenu_AppendItemW(hMenu, lpText, uID, icon, hMenuPopup, nItemHeight); else { - DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, NULL, 0 ); - LPWSTR lpszText = (LPWSTR)HeapAlloc ( GetProcessHeap(), 0, len*sizeof(WCHAR) ); + DWORD len = MultiByteToWideChar( CP_ACP, 0, lpText, -1, NULL, 0 ); + LPWSTR lpszText = HeapAlloc ( GetProcessHeap(), 0, len*sizeof(WCHAR) ); if (!lpszText) return FALSE; - MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, lpszText, len ); + MultiByteToWideChar( CP_ACP, 0, lpText, -1, lpszText, len ); ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight); HeapFree( GetProcessHeap(), 0, lpszText ); } @@ -747,7 +748,7 @@ /************************************************************************* * FileMenu_DeleteItemByFirstID [SHELL32.141] */ -EXTERN_C BOOL WINAPI FileMenu_DeleteItemByFirstID( +BOOL WINAPI FileMenu_DeleteItemByFirstID( HMENU hMenu, UINT uID) { @@ -854,8 +855,7 @@ * Shell_MergeMenus [SHELL32.67] */ UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags) -{ - int nItem; +{ int nItem; HMENU hmSubMenu; BOOL bAlreadySeparated; MENUITEMINFOW miiSrc;
10 years
1
0
0
0
[akhaldi] 65284: [SHELL32] * Partial sync of shlmenu.c with Wine 1.7.27. CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 6 12:57:39 2014 New Revision: 65284 URL:
http://svn.reactos.org/svn/reactos?rev=65284&view=rev
Log: [SHELL32] * Partial sync of shlmenu.c with Wine 1.7.27. CORE-8540 Modified: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c Modified: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c [iso-8859-1] Thu Nov 6 12:57:39 2014 @@ -45,599 +45,598 @@ typedef struct { - BOOL bInitialized; - BOOL bFixedItems; - /* create */ - COLORREF crBorderColor; - int nBorderWidth; - HBITMAP hBorderBmp; - - /* insert using pidl */ - LPITEMIDLIST pidl; - UINT uID; - UINT uFlags; - UINT uEnumFlags; - LPFNFMCALLBACK lpfnCallback; + BOOL bInitialized; + BOOL bFixedItems; + /* create */ + COLORREF crBorderColor; + int nBorderWidth; + HBITMAP hBorderBmp; + + /* insert using pidl */ + LPITEMIDLIST pidl; + UINT uID; + UINT uFlags; + UINT uEnumFlags; + LPFNFMCALLBACK lpfnCallback; } FMINFO, *LPFMINFO; typedef struct -{ int cchItemText; - int iIconIndex; - HMENU hMenu; - WCHAR szItemText[1]; +{ int cchItemText; + int iIconIndex; + HMENU hMenu; + WCHAR szItemText[1]; } FMITEM, * LPFMITEM; static BOOL bAbortInit; -#define CCH_MAXITEMTEXT 256 +#define CCH_MAXITEMTEXT 256 static LPFMINFO FM_GetMenuInfo(HMENU hmenu) { - MENUINFO MenuInfo; - LPFMINFO menudata; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hmenu, &MenuInfo)) - return NULL; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - return menudata; - -} -/************************************************************************* - * FM_SetMenuParameter [internal] + MENUINFO MenuInfo; + LPFMINFO menudata; + + MenuInfo.cbSize = sizeof(MENUINFO); + MenuInfo.fMask = MIM_MENUDATA; + + if (! GetMenuInfo(hmenu, &MenuInfo)) + return NULL; + + menudata = (LPFMINFO)MenuInfo.dwMenuData; + + if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) + { + ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); + return 0; + } + + return menudata; + +} +/************************************************************************* + * FM_SetMenuParameter [internal] * */ static LPFMINFO FM_SetMenuParameter( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - LPFMINFO menudata; - - TRACE("\n"); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree(menudata->pidl); - - menudata->uID = uID; - menudata->pidl = ILClone(pidl); - menudata->uFlags = uFlags; - menudata->uEnumFlags = uEnumFlags; - menudata->lpfnCallback = lpfnCallback; - - return menudata; -} - -/************************************************************************* - * FM_InitMenuPopup [internal] + HMENU hmenu, + UINT uID, + LPCITEMIDLIST pidl, + UINT uFlags, + UINT uEnumFlags, + LPFNFMCALLBACK lpfnCallback) +{ + LPFMINFO menudata; + + TRACE("\n"); + + menudata = FM_GetMenuInfo(hmenu); + + SHFree(menudata->pidl); + + menudata->uID = uID; + menudata->pidl = ILClone(pidl); + menudata->uFlags = uFlags; + menudata->uEnumFlags = uEnumFlags; + menudata->lpfnCallback = lpfnCallback; + + return menudata; +} + +/************************************************************************* + * FM_InitMenuPopup [internal] * */ static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) { IShellFolder *lpsf; IShellFolder *lpsf2; - ULONG ulItemAttr = SFGAO_FOLDER; - UINT uID, uEnumFlags; - LPFNFMCALLBACK lpfnCallback; - LPCITEMIDLIST pidl; - WCHAR sTemp[MAX_PATH]; - int NumberOfItems = 0, iIcon; - MENUINFO MenuInfo; - LPFMINFO menudata; - - TRACE("%p %p\n", hmenu, pAlternatePidl); - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (!GetMenuInfo(hmenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO) MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - if (menudata->bInitialized) - return 0; - - pidl = (pAlternatePidl ? pAlternatePidl : menudata->pidl); - if (!pidl) - return 0; - - uID = menudata->uID; - uEnumFlags = menudata->uEnumFlags; - lpfnCallback = menudata->lpfnCallback; - menudata->bInitialized = FALSE; - - SetMenuInfo(hmenu, &MenuInfo); - - if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) - { - if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2))) - { + ULONG ulItemAttr = SFGAO_FOLDER; + UINT uID, uEnumFlags; + LPFNFMCALLBACK lpfnCallback; + LPCITEMIDLIST pidl; + WCHAR sTemp[MAX_PATH]; + int NumberOfItems = 0, iIcon; + MENUINFO MenuInfo; + LPFMINFO menudata; + + TRACE("%p %p\n", hmenu, pAlternatePidl); + + MenuInfo.cbSize = sizeof(MENUINFO); + MenuInfo.fMask = MIM_MENUDATA; + + if (! GetMenuInfo(hmenu, &MenuInfo)) + return FALSE; + + menudata = (LPFMINFO)MenuInfo.dwMenuData; + + if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) + { + ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); + return 0; + } + + if (menudata->bInitialized) + return 0; + + pidl = (pAlternatePidl? pAlternatePidl: menudata->pidl); + if (!pidl) + return 0; + + uID = menudata->uID; + uEnumFlags = menudata->uEnumFlags; + lpfnCallback = menudata->lpfnCallback; + menudata->bInitialized = FALSE; + + SetMenuInfo(hmenu, &MenuInfo); + + if (SUCCEEDED (SHGetDesktopFolder(&lpsf))) + { + if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2))) + { IEnumIDList *lpe; - if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe ))) - { - - LPITEMIDLIST pidlTemp = NULL; - ULONG ulFetched; - - while ((!bAbortInit) && (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))) - { - if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr))) - { - ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING); - if (!(PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon))) - iIcon = FM_BLANK_ICON; - if (SFGAO_FOLDER & ulItemAttr) - { - LPFMINFO lpFmMi; - MENUINFO MenuInfo; - HMENU hMenuPopup = CreatePopupMenu(); + if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe ))) + { + + LPITEMIDLIST pidlTemp = NULL; + ULONG ulFetched; + + while ((!bAbortInit) && (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))) + { + if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr))) + { + ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING); + if (! (PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon))) + iIcon = FM_BLANK_ICON; + if ( SFGAO_FOLDER & ulItemAttr) + { + LPFMINFO lpFmMi; + MENUINFO MenuInfo; + HMENU hMenuPopup = CreatePopupMenu(); lpFmMi = (LPFMINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - lpFmMi->pidl = ILCombine(pidl, pidlTemp); - lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi; - SetMenuInfo(hMenuPopup, &MenuInfo); - - FileMenu_AppendItemW(hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT); - } - else - { - LPWSTR pExt = PathFindExtensionW(sTemp); - if (pExt) - *pExt = 0; - FileMenu_AppendItemW(hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT); - } - } - - if (lpfnCallback) - { - TRACE("enter callback\n"); - lpfnCallback(pidl, pidlTemp); - TRACE("leave callback\n"); - } - - NumberOfItems++; - } - } - } - } - - if (GetMenuItemCount(hmenu) == 0) - { - static const WCHAR szEmpty [] = { '(', 'e', 'm', 'p', 't', 'y', ')', 0 }; - FileMenu_AppendItemW(hmenu, szEmpty, uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT); - NumberOfItems++; - } - - menudata->bInitialized = TRUE; - SetMenuInfo(hmenu, &MenuInfo); - - return NumberOfItems; -} - -/************************************************************************* - * FileMenu_Create [SHELL32.114] + lpFmMi->pidl = ILCombine(pidl, pidlTemp); + lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; + + MenuInfo.cbSize = sizeof(MENUINFO); + MenuInfo.fMask = MIM_MENUDATA; + MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi; + SetMenuInfo (hMenuPopup, &MenuInfo); + + FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT); + } + else + { + LPWSTR pExt = PathFindExtensionW(sTemp); + if (pExt) + *pExt = 0; + FileMenu_AppendItemW (hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT); + } + } + + if (lpfnCallback) + { + TRACE("enter callback\n"); + lpfnCallback ( pidl, pidlTemp); + TRACE("leave callback\n"); + } + + NumberOfItems++; + } + } + } + } + + if ( GetMenuItemCount (hmenu) == 0 ) + { + static const WCHAR szEmpty[] = { '(','e','m','p','t','y',')',0 }; + FileMenu_AppendItemW (hmenu, szEmpty, uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT); + NumberOfItems++; + } + + menudata->bInitialized = TRUE; + SetMenuInfo(hmenu, &MenuInfo); + + return NumberOfItems; +} +/************************************************************************* + * FileMenu_Create [SHELL32.114] * * NOTES * for non-root menus values are * (ffffffff,00000000,00000000,00000000,00000000) */ HMENU WINAPI FileMenu_Create ( - COLORREF crBorderColor, - int nBorderWidth, - HBITMAP hBorderBmp, - int nSelHeight, - UINT uFlags) -{ - MENUINFO MenuInfo; - LPFMINFO menudata; - - HMENU hMenu = CreatePopupMenu(); - - TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", - crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); + COLORREF crBorderColor, + int nBorderWidth, + HBITMAP hBorderBmp, + int nSelHeight, + UINT uFlags) +{ + MENUINFO MenuInfo; + LPFMINFO menudata; + + HMENU hMenu = CreatePopupMenu(); + + TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", + crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); menudata = (LPFMINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - menudata->crBorderColor = crBorderColor; - menudata->nBorderWidth = nBorderWidth; - menudata->hBorderBmp = hBorderBmp; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) menudata; - SetMenuInfo (hMenu, &MenuInfo); - - return hMenu; -} - -/************************************************************************* - * FileMenu_Destroy [SHELL32.118] + menudata->crBorderColor = crBorderColor; + menudata->nBorderWidth = nBorderWidth; + menudata->hBorderBmp = hBorderBmp; + + MenuInfo.cbSize = sizeof(MENUINFO); + MenuInfo.fMask = MIM_MENUDATA; + MenuInfo.dwMenuData = (ULONG_PTR) menudata; + SetMenuInfo (hMenu, &MenuInfo); + + return hMenu; +} + +/************************************************************************* + * FileMenu_Destroy [SHELL32.118] * * NOTES * exported by name */ void WINAPI FileMenu_Destroy (HMENU hmenu) { - LPFMINFO menudata; - - TRACE("%p\n", hmenu); - - FileMenu_DeleteAllItems (hmenu); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree( menudata->pidl); - HeapFree(GetProcessHeap(), 0, menudata); - - DestroyMenu (hmenu); -} - -/************************************************************************* - * FileMenu_AppendItem [SHELL32.115] + LPFMINFO menudata; + + TRACE("%p\n", hmenu); + + FileMenu_DeleteAllItems (hmenu); + + menudata = FM_GetMenuInfo(hmenu); + + SHFree( menudata->pidl); + HeapFree(GetProcessHeap(), 0, menudata); + + DestroyMenu (hmenu); +} + +/************************************************************************* + * FileMenu_AppendItem [SHELL32.115] * */ static BOOL FileMenu_AppendItemW( - HMENU hMenu, - LPCWSTR lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - MENUITEMINFOW mii; - LPFMITEM myItem; - LPFMINFO menudata; - MENUINFO MenuInfo; - - - TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n", - hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL, - uID, icon, hMenuPopup, nItemHeight); - - ZeroMemory (&mii, sizeof(MENUITEMINFOW)); - - mii.cbSize = sizeof(MENUITEMINFOW); - - if (lpText != FM_SEPARATOR) - { - int len = strlenW (lpText); + HMENU hMenu, + LPCWSTR lpText, + UINT uID, + int icon, + HMENU hMenuPopup, + int nItemHeight) +{ + MENUITEMINFOW mii; + LPFMITEM myItem; + LPFMINFO menudata; + MENUINFO MenuInfo; + + + TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n", + hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL, + uID, icon, hMenuPopup, nItemHeight); + + ZeroMemory (&mii, sizeof(MENUITEMINFOW)); + + mii.cbSize = sizeof(MENUITEMINFOW); + + if (lpText != FM_SEPARATOR) + { + int len = strlenW (lpText); myItem = (LPFMITEM)SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR)); wcscpy (myItem->szItemText, lpText); - myItem->cchItemText = len; - myItem->iIconIndex = icon; - myItem->hMenu = hMenu; - mii.fMask = MIIM_DATA; - mii.dwItemData = (ULONG_PTR) myItem; - } - - if ( hMenuPopup ) - { /* sub menu */ - mii.fMask |= MIIM_TYPE | MIIM_SUBMENU; - mii.fType = MFT_OWNERDRAW; - mii.hSubMenu = hMenuPopup; - } - else if (lpText == FM_SEPARATOR ) - { mii.fMask |= MIIM_ID | MIIM_TYPE; - mii.fType = MFT_SEPARATOR; - } - else - { /* normal item */ - mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE; - mii.fState = MFS_ENABLED | MFS_DEFAULT; - mii.fType = MFT_OWNERDRAW; - } - mii.wID = uID; - - InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii); - - /* set bFixedItems to true */ - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hMenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return FALSE; - } - - menudata->bFixedItems = TRUE; - SetMenuInfo(hMenu, &MenuInfo); - - return TRUE; + myItem->cchItemText = len; + myItem->iIconIndex = icon; + myItem->hMenu = hMenu; + mii.fMask = MIIM_DATA; + mii.dwItemData = (ULONG_PTR) myItem; + } + + if ( hMenuPopup ) + { /* sub menu */ + mii.fMask |= MIIM_TYPE | MIIM_SUBMENU; + mii.fType = MFT_OWNERDRAW; + mii.hSubMenu = hMenuPopup; + } + else if (lpText == FM_SEPARATOR ) + { mii.fMask |= MIIM_ID | MIIM_TYPE; + mii.fType = MFT_SEPARATOR; + } + else + { /* normal item */ + mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE; + mii.fState = MFS_ENABLED | MFS_DEFAULT; + mii.fType = MFT_OWNERDRAW; + } + mii.wID = uID; + + InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii); + + /* set bFixedItems to true */ + MenuInfo.cbSize = sizeof(MENUINFO); + MenuInfo.fMask = MIM_MENUDATA; + + if (! GetMenuInfo(hMenu, &MenuInfo)) + return FALSE; + + menudata = (LPFMINFO)MenuInfo.dwMenuData; + if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) + { + ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); + return FALSE; + } + + menudata->bFixedItems = TRUE; + SetMenuInfo(hMenu, &MenuInfo); + + return TRUE; } /**********************************************************************/ EXTERN_C BOOL WINAPI FileMenu_AppendItemAW( - HMENU hMenu, - LPCVOID lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - BOOL ret; + HMENU hMenu, + LPCVOID lpText, + UINT uID, + int icon, + HMENU hMenuPopup, + int nItemHeight) +{ + BOOL ret; if (!lpText) return FALSE; - if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR) + if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR) ret = FileMenu_AppendItemW(hMenu, (LPWSTR)lpText, uID, icon, hMenuPopup, nItemHeight); else - { + { DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, NULL, 0 ); LPWSTR lpszText = (LPWSTR)HeapAlloc ( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - if (!lpszText) return FALSE; + if (!lpszText) return FALSE; MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, lpszText, len ); - ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight); - HeapFree( GetProcessHeap(), 0, lpszText ); - } - - return ret; -} - -/************************************************************************* - * FileMenu_InsertUsingPidl [SHELL32.110] + ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight); + HeapFree( GetProcessHeap(), 0, lpszText ); + } + + return ret; +} + +/************************************************************************* + * FileMenu_InsertUsingPidl [SHELL32.110] * * NOTES - * uEnumFlags any SHCONTF flag + * uEnumFlags any SHCONTF flag */ int WINAPI FileMenu_InsertUsingPidl ( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - pdump (pidl); - - bAbortInit = FALSE; - - FM_SetMenuParameter(hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_ReplaceUsingPidl [SHELL32.113] + HMENU hmenu, + UINT uID, + LPCITEMIDLIST pidl, + UINT uFlags, + UINT uEnumFlags, + LPFNFMCALLBACK lpfnCallback) +{ + TRACE("%p 0x%08x %p 0x%08x 0x%08x %p\n", + hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); + + pdump (pidl); + + bAbortInit = FALSE; + + FM_SetMenuParameter(hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); + + return FM_InitMenuPopup(hmenu, NULL); +} + +/************************************************************************* + * FileMenu_ReplaceUsingPidl [SHELL32.113] * * FIXME: the static items are deleted but won't be refreshed */ int WINAPI FileMenu_ReplaceUsingPidl( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x %p\n", - hmenu, uID, pidl, uEnumFlags, lpfnCallback); - - FileMenu_DeleteAllItems (hmenu); - - FM_SetMenuParameter(hmenu, uID, pidl, 0, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_Invalidate [SHELL32.111] + HMENU hmenu, + UINT uID, + LPCITEMIDLIST pidl, + UINT uEnumFlags, + LPFNFMCALLBACK lpfnCallback) +{ + TRACE("%p 0x%08x %p 0x%08x %p\n", + hmenu, uID, pidl, uEnumFlags, lpfnCallback); + + FileMenu_DeleteAllItems (hmenu); + + FM_SetMenuParameter(hmenu, uID, pidl, 0, uEnumFlags, lpfnCallback); + + return FM_InitMenuPopup(hmenu, NULL); +} + +/************************************************************************* + * FileMenu_Invalidate [SHELL32.111] */ void WINAPI FileMenu_Invalidate (HMENU hMenu) { - FIXME("%p\n",hMenu); -} - -/************************************************************************* - * FileMenu_FindSubMenuByPidl [SHELL32.106] + FIXME("%p\n",hMenu); +} + +/************************************************************************* + * FileMenu_FindSubMenuByPidl [SHELL32.106] */ HMENU WINAPI FileMenu_FindSubMenuByPidl( - HMENU hMenu, - LPCITEMIDLIST pidl) -{ - FIXME("%p %p\n",hMenu, pidl); - return 0; -} - -/************************************************************************* - * FileMenu_AppendFilesForPidl [SHELL32.124] + HMENU hMenu, + LPCITEMIDLIST pidl) +{ + FIXME("%p %p\n",hMenu, pidl); + return 0; +} + +/************************************************************************* + * FileMenu_AppendFilesForPidl [SHELL32.124] */ int WINAPI FileMenu_AppendFilesForPidl( - HMENU hmenu, - LPCITEMIDLIST pidl, - BOOL bAddSeparator) -{ - LPFMINFO menudata; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - FM_InitMenuPopup(hmenu, pidl); - - if (bAddSeparator) - FileMenu_AppendItemW (hmenu, FM_SEPARATOR, 0, 0, 0, FM_DEFAULT_HEIGHT); - - TRACE("%p %p 0x%08x\n",hmenu, pidl,bAddSeparator); - - return 0; -} -/************************************************************************* - * FileMenu_AddFilesForPidl [SHELL32.125] + HMENU hmenu, + LPCITEMIDLIST pidl, + BOOL bAddSeparator) +{ + LPFMINFO menudata; + + menudata = FM_GetMenuInfo(hmenu); + + menudata->bInitialized = FALSE; + + FM_InitMenuPopup(hmenu, pidl); + + if (bAddSeparator) + FileMenu_AppendItemW (hmenu, FM_SEPARATOR, 0, 0, 0, FM_DEFAULT_HEIGHT); + + TRACE("%p %p 0x%08x\n",hmenu, pidl,bAddSeparator); + + return 0; +} +/************************************************************************* + * FileMenu_AddFilesForPidl [SHELL32.125] * * NOTES - * uEnumFlags any SHCONTF flag + * uEnumFlags any SHCONTF flag */ int WINAPI FileMenu_AddFilesForPidl ( - HMENU hmenu, - UINT uReserved, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uReserved, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FileMenu_InsertUsingPidl ( hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - -} - - -/************************************************************************* - * FileMenu_TrackPopupMenuEx [SHELL32.116] + HMENU hmenu, + UINT uReserved, + UINT uID, + LPCITEMIDLIST pidl, + UINT uFlags, + UINT uEnumFlags, + LPFNFMCALLBACK lpfnCallback) +{ + TRACE("%p 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n", + hmenu, uReserved, uID, pidl, uFlags, uEnumFlags, lpfnCallback); + + return FileMenu_InsertUsingPidl ( hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); + +} + + +/************************************************************************* + * FileMenu_TrackPopupMenuEx [SHELL32.116] */ BOOL WINAPI FileMenu_TrackPopupMenuEx ( - HMENU hMenu, - UINT uFlags, - int x, - int y, - HWND hWnd, - LPTPMPARAMS lptpm) -{ - TRACE("%p 0x%08x 0x%x 0x%x %p %p\n", - hMenu, uFlags, x, y, hWnd, lptpm); - return TrackPopupMenuEx(hMenu, uFlags, x, y, hWnd, lptpm); -} - -/************************************************************************* - * FileMenu_GetLastSelectedItemPidls [SHELL32.107] + HMENU hMenu, + UINT uFlags, + int x, + int y, + HWND hWnd, + LPTPMPARAMS lptpm) +{ + TRACE("%p 0x%08x 0x%x 0x%x %p %p\n", + hMenu, uFlags, x, y, hWnd, lptpm); + return TrackPopupMenuEx(hMenu, uFlags, x, y, hWnd, lptpm); +} + +/************************************************************************* + * FileMenu_GetLastSelectedItemPidls [SHELL32.107] */ BOOL WINAPI FileMenu_GetLastSelectedItemPidls( - UINT uReserved, - LPCITEMIDLIST *ppidlFolder, - LPCITEMIDLIST *ppidlItem) -{ - FIXME("0x%08x %p %p\n",uReserved, ppidlFolder, ppidlItem); - return FALSE; -} - -#define FM_ICON_SIZE 16 -#define FM_Y_SPACE 4 -#define FM_SPACE1 4 -#define FM_SPACE2 2 -#define FM_LEFTBORDER 2 -#define FM_RIGHTBORDER 8 -/************************************************************************* - * FileMenu_MeasureItem [SHELL32.112] + UINT uReserved, + LPCITEMIDLIST *ppidlFolder, + LPCITEMIDLIST *ppidlItem) +{ + FIXME("0x%08x %p %p\n",uReserved, ppidlFolder, ppidlItem); + return FALSE; +} + +#define FM_ICON_SIZE 16 +#define FM_Y_SPACE 4 +#define FM_SPACE1 4 +#define FM_SPACE2 2 +#define FM_LEFTBORDER 2 +#define FM_RIGHTBORDER 8 +/************************************************************************* + * FileMenu_MeasureItem [SHELL32.112] */ LRESULT WINAPI FileMenu_MeasureItem( - HWND hWnd, - LPMEASUREITEMSTRUCT lpmis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpmis->itemData); - HDC hdc = GetDC(hWnd); - SIZE size; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpmis, debugstr_w(pMyItem->szItemText)); - - GetTextExtentPoint32W(hdc, pMyItem->szItemText, pMyItem->cchItemText, &size); - - lpmis->itemWidth = size.cx + FM_LEFTBORDER + FM_ICON_SIZE + FM_SPACE1 + FM_SPACE2 + FM_RIGHTBORDER; - lpmis->itemHeight = (size.cy > (FM_ICON_SIZE + FM_Y_SPACE)) ? size.cy : (FM_ICON_SIZE + FM_Y_SPACE); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - lpmis->itemWidth += menuinfo->nBorderWidth; - - TRACE("-- 0x%04x 0x%04x\n", lpmis->itemWidth, lpmis->itemHeight); - ReleaseDC (hWnd, hdc); - return 0; -} -/************************************************************************* - * FileMenu_DrawItem [SHELL32.105] + HWND hWnd, + LPMEASUREITEMSTRUCT lpmis) +{ + LPFMITEM pMyItem = (LPFMITEM)(lpmis->itemData); + HDC hdc = GetDC(hWnd); + SIZE size; + LPFMINFO menuinfo; + + TRACE("%p %p %s\n", hWnd, lpmis, debugstr_w(pMyItem->szItemText)); + + GetTextExtentPoint32W(hdc, pMyItem->szItemText, pMyItem->cchItemText, &size); + + lpmis->itemWidth = size.cx + FM_LEFTBORDER + FM_ICON_SIZE + FM_SPACE1 + FM_SPACE2 + FM_RIGHTBORDER; + lpmis->itemHeight = (size.cy > (FM_ICON_SIZE + FM_Y_SPACE)) ? size.cy : (FM_ICON_SIZE + FM_Y_SPACE); + + /* add the menubitmap */ + menuinfo = FM_GetMenuInfo(pMyItem->hMenu); + if (menuinfo->nBorderWidth) + lpmis->itemWidth += menuinfo->nBorderWidth; + + TRACE("-- 0x%04x 0x%04x\n", lpmis->itemWidth, lpmis->itemHeight); + ReleaseDC (hWnd, hdc); + return 0; +} +/************************************************************************* + * FileMenu_DrawItem [SHELL32.105] */ LRESULT WINAPI FileMenu_DrawItem( - HWND hWnd, - LPDRAWITEMSTRUCT lpdis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpdis->itemData); - COLORREF clrPrevText, clrPrevBkgnd; - int xi,yi,xt,yt; - HIMAGELIST hImageList; - RECT TextRect; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpdis, debugstr_w(pMyItem->szItemText)); - - if (lpdis->itemState & ODS_SELECTED) - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT)); - } - else - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_MENUTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_MENU)); - } - - CopyRect(&TextRect, &(lpdis->rcItem)); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - TextRect.left += menuinfo->nBorderWidth; - - TextRect.left += FM_LEFTBORDER; - xi = TextRect.left + FM_SPACE1; - yi = TextRect.top + FM_Y_SPACE/2; - TextRect.bottom -= FM_Y_SPACE/2; - - xt = xi + FM_ICON_SIZE + FM_SPACE2; - yt = yi; - - ExtTextOutW (lpdis->hDC, xt , yt, ETO_OPAQUE, &TextRect, pMyItem->szItemText, pMyItem->cchItemText, NULL); - - Shell_GetImageLists(0, &hImageList); - ImageList_Draw(hImageList, pMyItem->iIconIndex, lpdis->hDC, xi, yi, ILD_NORMAL); - - TRACE("-- 0x%04x 0x%04x 0x%04x 0x%04x\n", TextRect.left, TextRect.top, TextRect.right, TextRect.bottom); - - SetTextColor(lpdis->hDC, clrPrevText); - SetBkColor(lpdis->hDC, clrPrevBkgnd); - - return TRUE; -} - -/************************************************************************* - * FileMenu_InitMenuPopup [SHELL32.109] + HWND hWnd, + LPDRAWITEMSTRUCT lpdis) +{ + LPFMITEM pMyItem = (LPFMITEM)(lpdis->itemData); + COLORREF clrPrevText, clrPrevBkgnd; + int xi,yi,xt,yt; + HIMAGELIST hImageList; + RECT TextRect; + LPFMINFO menuinfo; + + TRACE("%p %p %s\n", hWnd, lpdis, debugstr_w(pMyItem->szItemText)); + + if (lpdis->itemState & ODS_SELECTED) + { + clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT)); + clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT)); + } + else + { + clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_MENUTEXT)); + clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_MENU)); + } + + CopyRect(&TextRect, &(lpdis->rcItem)); + + /* add the menubitmap */ + menuinfo = FM_GetMenuInfo(pMyItem->hMenu); + if (menuinfo->nBorderWidth) + TextRect.left += menuinfo->nBorderWidth; + + TextRect.left += FM_LEFTBORDER; + xi = TextRect.left + FM_SPACE1; + yi = TextRect.top + FM_Y_SPACE/2; + TextRect.bottom -= FM_Y_SPACE/2; + + xt = xi + FM_ICON_SIZE + FM_SPACE2; + yt = yi; + + ExtTextOutW (lpdis->hDC, xt , yt, ETO_OPAQUE, &TextRect, pMyItem->szItemText, pMyItem->cchItemText, NULL); + + Shell_GetImageLists(0, &hImageList); + ImageList_Draw(hImageList, pMyItem->iIconIndex, lpdis->hDC, xi, yi, ILD_NORMAL); + + TRACE("-- 0x%04x 0x%04x 0x%04x 0x%04x\n", TextRect.left, TextRect.top, TextRect.right, TextRect.bottom); + + SetTextColor(lpdis->hDC, clrPrevText); + SetBkColor(lpdis->hDC, clrPrevBkgnd); + + return TRUE; +} + +/************************************************************************* + * FileMenu_InitMenuPopup [SHELL32.109] * * NOTES * The filemenu is an ownerdrawn menu. Call this function responding to @@ -646,186 +645,186 @@ */ BOOL WINAPI FileMenu_InitMenuPopup (HMENU hmenu) { - FM_InitMenuPopup(hmenu, NULL); - return TRUE; -} - -/************************************************************************* - * FileMenu_HandleMenuChar [SHELL32.108] + FM_InitMenuPopup(hmenu, NULL); + return TRUE; +} + +/************************************************************************* + * FileMenu_HandleMenuChar [SHELL32.108] */ LRESULT WINAPI FileMenu_HandleMenuChar( - HMENU hMenu, - WPARAM wParam) -{ - FIXME("%p 0x%08lx\n",hMenu,wParam); - return 0; -} - -/************************************************************************* - * FileMenu_DeleteAllItems [SHELL32.104] + HMENU hMenu, + WPARAM wParam) +{ + FIXME("%p 0x%08lx\n",hMenu,wParam); + return 0; +} + +/************************************************************************* + * FileMenu_DeleteAllItems [SHELL32.104] * * NOTES * exported by name */ BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu) { - MENUITEMINFOW mii; - LPFMINFO menudata; - - int i; - - TRACE("%p\n", hmenu); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU|MIIM_DATA; - - for (i = 0; i < GetMenuItemCount( hmenu ); i++) - { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); - - SHFree((LPFMINFO)mii.dwItemData); - - if (mii.hSubMenu) - FileMenu_Destroy(mii.hSubMenu); - } - - while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){}; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByCmd [SHELL32.117] + MENUITEMINFOW mii; + LPFMINFO menudata; + + int i; + + TRACE("%p\n", hmenu); + + ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); + mii.cbSize = sizeof(MENUITEMINFOW); + mii.fMask = MIIM_SUBMENU|MIIM_DATA; + + for (i = 0; i < GetMenuItemCount( hmenu ); i++) + { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); + + SHFree((LPFMINFO)mii.dwItemData); + + if (mii.hSubMenu) + FileMenu_Destroy(mii.hSubMenu); + } + + while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){}; + + menudata = FM_GetMenuInfo(hmenu); + + menudata->bInitialized = FALSE; + + return TRUE; +} + +/************************************************************************* + * FileMenu_DeleteItemByCmd [SHELL32.117] * */ BOOL WINAPI FileMenu_DeleteItemByCmd (HMENU hMenu, UINT uID) { - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uID); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uID, FALSE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYCOMMAND, uID); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByIndex [SHELL32.140] + MENUITEMINFOW mii; + + TRACE("%p 0x%08x\n", hMenu, uID); + + ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); + mii.cbSize = sizeof(MENUITEMINFOW); + mii.fMask = MIIM_SUBMENU; + + GetMenuItemInfoW(hMenu, uID, FALSE, &mii ); + if ( mii.hSubMenu ) + { + /* FIXME: Do what? */ + } + + DeleteMenu(hMenu, MF_BYCOMMAND, uID); + return TRUE; +} + +/************************************************************************* + * FileMenu_DeleteItemByIndex [SHELL32.140] */ BOOL WINAPI FileMenu_DeleteItemByIndex ( HMENU hMenu, UINT uPos) { - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uPos); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uPos, TRUE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYPOSITION, uPos); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByFirstID [SHELL32.141] + MENUITEMINFOW mii; + + TRACE("%p 0x%08x\n", hMenu, uPos); + + ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); + mii.cbSize = sizeof(MENUITEMINFOW); + mii.fMask = MIIM_SUBMENU; + + GetMenuItemInfoW(hMenu, uPos, TRUE, &mii ); + if ( mii.hSubMenu ) + { + /* FIXME: Do what? */ + } + + DeleteMenu(hMenu, MF_BYPOSITION, uPos); + return TRUE; +} + +/************************************************************************* + * FileMenu_DeleteItemByFirstID [SHELL32.141] */ EXTERN_C BOOL WINAPI FileMenu_DeleteItemByFirstID( - HMENU hMenu, - UINT uID) -{ - TRACE("%p 0x%08x\n", hMenu, uID); - return FALSE; -} - -/************************************************************************* - * FileMenu_DeleteSeparator [SHELL32.142] + HMENU hMenu, + UINT uID) +{ + TRACE("%p 0x%08x\n", hMenu, uID); + return FALSE; +} + +/************************************************************************* + * FileMenu_DeleteSeparator [SHELL32.142] */ BOOL WINAPI FileMenu_DeleteSeparator(HMENU hMenu) { - TRACE("%p\n", hMenu); - return FALSE; -} - -/************************************************************************* - * FileMenu_EnableItemByCmd [SHELL32.143] + TRACE("%p\n", hMenu); + return FALSE; +} + +/************************************************************************* + * FileMenu_EnableItemByCmd [SHELL32.143] */ BOOL WINAPI FileMenu_EnableItemByCmd( - HMENU hMenu, - UINT uID, - BOOL bEnable) -{ - TRACE("%p 0x%08x 0x%08x\n", hMenu, uID,bEnable); - return FALSE; -} - -/************************************************************************* - * FileMenu_GetItemExtent [SHELL32.144] + HMENU hMenu, + UINT uID, + BOOL bEnable) +{ + TRACE("%p 0x%08x 0x%08x\n", hMenu, uID,bEnable); + return FALSE; +} + +/************************************************************************* + * FileMenu_GetItemExtent [SHELL32.144] * * NOTES * if the menu is too big, entries are getting cut away!! */ DWORD WINAPI FileMenu_GetItemExtent (HMENU hMenu, UINT uPos) -{ RECT rect; - - FIXME("%p 0x%08x\n", hMenu, uPos); - - if (GetMenuItemRect(0, hMenu, uPos, &rect)) - { FIXME("0x%04x 0x%04x 0x%04x 0x%04x\n", - rect.right, rect.left, rect.top, rect.bottom); - return ((rect.right-rect.left)<<16) + (rect.top-rect.bottom); - } - return 0x00100010; /*FIXME*/ -} - -/************************************************************************* - * FileMenu_AbortInitMenu [SHELL32.120] +{ RECT rect; + + FIXME("%p 0x%08x\n", hMenu, uPos); + + if (GetMenuItemRect(0, hMenu, uPos, &rect)) + { FIXME("0x%04x 0x%04x 0x%04x 0x%04x\n", + rect.right, rect.left, rect.top, rect.bottom); + return ((rect.right-rect.left)<<16) + (rect.top-rect.bottom); + } + return 0x00100010; /*FIXME*/ +} + +/************************************************************************* + * FileMenu_AbortInitMenu [SHELL32.120] * */ void WINAPI FileMenu_AbortInitMenu (void) -{ TRACE("\n"); - bAbortInit = TRUE; -} - -/************************************************************************* - * SHFind_InitMenuPopup [SHELL32.149] +{ TRACE("\n"); + bAbortInit = TRUE; +} + +/************************************************************************* + * SHFind_InitMenuPopup [SHELL32.149] * * Get the IContextMenu instance for the submenu of options displayed * for the Search entry in the Classic style Start menu. * * PARAMETERS - * hMenu [in] handle of menu previously created - * hWndParent [in] parent window - * w [in] no pointer (0x209 over here) perhaps menu IDs ??? - * x [in] no pointer (0x226 over here) + * hMenu [in] handle of menu previously created + * hWndParent [in] parent window + * w [in] no pointer (0x209 over here) perhaps menu IDs ??? + * x [in] no pointer (0x226 over here) * * RETURNS - * LPXXXXX pointer to struct containing a func addr at offset 8 - * or NULL at failure. + * LPXXXXX pointer to struct containing a func addr at offset 8 + * or NULL at failure. */ EXTERN_C IContextMenu * WINAPI SHFind_InitMenuPopup (HMENU hMenu, HWND hWndParent, UINT w, UINT x) { - FIXME("hmenu=%p hwnd=%p 0x%08x 0x%08x stub\n", - hMenu,hWndParent,w,x); - return NULL; /* this is supposed to be a pointer */ + FIXME("hmenu=%p hwnd=%p 0x%08x 0x%08x stub\n", + hMenu,hWndParent,w,x); + return NULL; /* this is supposed to be a pointer */ } /************************************************************************* @@ -833,167 +832,167 @@ */ static BOOL _SHIsMenuSeparator(HMENU hm, int i) { - MENUITEMINFOW mii; - - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_TYPE; - mii.cch = 0; /* WARNING: We MUST initialize it to 0*/ - if (!GetMenuItemInfoW(hm, i, TRUE, &mii)) - { - return(FALSE); - } - - if (mii.fType & MFT_SEPARATOR) - { - return(TRUE); - } - - return(FALSE); -} - -/************************************************************************* - * Shell_MergeMenus [SHELL32.67] + MENUITEMINFOW mii; + + mii.cbSize = sizeof(MENUITEMINFOW); + mii.fMask = MIIM_TYPE; + mii.cch = 0; /* WARNING: We MUST initialize it to 0*/ + if (!GetMenuItemInfoW(hm, i, TRUE, &mii)) + { + return(FALSE); + } + + if (mii.fType & MFT_SEPARATOR) + { + return(TRUE); + } + + return(FALSE); +} + +/************************************************************************* + * Shell_MergeMenus [SHELL32.67] */ UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags) { int nItem; - HMENU hmSubMenu; - BOOL bAlreadySeparated; - MENUITEMINFOW miiSrc; - WCHAR szName[256]; - UINT uTemp, uIDMax = uIDAdjust; - - TRACE("hmenu1=%p hmenu2=%p 0x%04x 0x%04x 0x%04x 0x%04x\n", - hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags); - - if (!hmDst || !hmSrc) - return uIDMax; - - nItem = GetMenuItemCount(hmDst); - if (nItem == -1) - return uIDMax; - - if (uInsert >= (UINT)nItem) /* insert position inside menu? */ - { - uInsert = (UINT)nItem; /* append on the end */ - bAlreadySeparated = TRUE; - } - else - { - bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert); - } - - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus */ - InsertMenuA(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - bAlreadySeparated = TRUE; - } - - - /* Go through the menu items and clone them*/ - for (nItem = GetMenuItemCount(hmSrc) - 1; nItem >= 0; nItem--) - { - miiSrc.cbSize = sizeof(MENUITEMINFOW); - miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA; - - /* We need to reset this every time through the loop in case menus DON'T have IDs*/ - miiSrc.fType = MFT_STRING; - miiSrc.dwTypeData = szName; - miiSrc.dwItemData = 0; - miiSrc.cch = sizeof(szName)/sizeof(WCHAR); - - if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc)) - { - continue; - } - -/* TRACE("found menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmSrc, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); + HMENU hmSubMenu; + BOOL bAlreadySeparated; + MENUITEMINFOW miiSrc; + WCHAR szName[256]; + UINT uTemp, uIDMax = uIDAdjust; + + TRACE("hmenu1=%p hmenu2=%p 0x%04x 0x%04x 0x%04x 0x%04x\n", + hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags); + + if (!hmDst || !hmSrc) + return uIDMax; + + nItem = GetMenuItemCount(hmDst); + if (nItem == -1) + return uIDMax; + + if (uInsert >= (UINT)nItem) /* insert position inside menu? */ + { + uInsert = (UINT)nItem; /* append on the end */ + bAlreadySeparated = TRUE; + } + else + { + bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert); + } + + if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) + { + /* Add a separator between the menus */ + InsertMenuA(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + bAlreadySeparated = TRUE; + } + + + /* Go through the menu items and clone them*/ + for (nItem = GetMenuItemCount(hmSrc) - 1; nItem >= 0; nItem--) + { + miiSrc.cbSize = sizeof(MENUITEMINFOW); + miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA; + + /* We need to reset this every time through the loop in case menus DON'T have IDs*/ + miiSrc.fType = MFT_STRING; + miiSrc.dwTypeData = szName; + miiSrc.dwItemData = 0; + miiSrc.cch = sizeof(szName)/sizeof(WCHAR); + + if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc)) + { + continue; + } + +/* TRACE("found menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmSrc, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); */ - if (miiSrc.fType & MFT_SEPARATOR) - { - /* This is a separator; don't put two of them in a row */ - if (bAlreadySeparated) - continue; - - bAlreadySeparated = TRUE; - } - else if (miiSrc.hSubMenu) - { - if (uFlags & MM_SUBMENUSHAVEIDS) - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - } - else - { - miiSrc.fMask &= ~MIIM_ID; /* Don't set IDs for submenus that didn't have them already */ - } - hmSubMenu = miiSrc.hSubMenu; - - miiSrc.hSubMenu = CreatePopupMenu(); - - if (!miiSrc.hSubMenu) return(uIDMax); - - uTemp = Shell_MergeMenus(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags & MM_SUBMENUSHAVEIDS); - - if (uIDMax <= uTemp) - uIDMax = uTemp; - - bAlreadySeparated = FALSE; - } - else /* normal menu item */ - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - - bAlreadySeparated = FALSE; - } - -/* TRACE("inserting menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmDst, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); + if (miiSrc.fType & MFT_SEPARATOR) + { + /* This is a separator; don't put two of them in a row */ + if (bAlreadySeparated) + continue; + + bAlreadySeparated = TRUE; + } + else if (miiSrc.hSubMenu) + { + if (uFlags & MM_SUBMENUSHAVEIDS) + { + miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ + + if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ + continue; + + if (uIDMax <= miiSrc.wID) /* remember the highest ID */ + uIDMax = miiSrc.wID + 1; + } + else + { + miiSrc.fMask &= ~MIIM_ID; /* Don't set IDs for submenus that didn't have them already */ + } + hmSubMenu = miiSrc.hSubMenu; + + miiSrc.hSubMenu = CreatePopupMenu(); + + if (!miiSrc.hSubMenu) return(uIDMax); + + uTemp = Shell_MergeMenus(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags & MM_SUBMENUSHAVEIDS); + + if (uIDMax <= uTemp) + uIDMax = uTemp; + + bAlreadySeparated = FALSE; + } + else /* normal menu item */ + { + miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ + + if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ + continue; + + if (uIDMax <= miiSrc.wID) /* remember the highest ID */ + uIDMax = miiSrc.wID + 1; + + bAlreadySeparated = FALSE; + } + +/* TRACE("inserting menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmDst, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); */ - if (!InsertMenuItemW(hmDst, uInsert, TRUE, &miiSrc)) - { - return(uIDMax); - } - } - - /* Ensure the correct number of separators at the beginning of the - inserted menu items*/ - if (uInsert == 0) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if (_SHIsMenuSeparator(hmDst, uInsert-1)) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus*/ - InsertMenuW(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - } - } - } - return(uIDMax); -} + if (!InsertMenuItemW(hmDst, uInsert, TRUE, &miiSrc)) + { + return(uIDMax); + } + } + + /* Ensure the correct number of separators at the beginning of the + inserted menu items*/ + if (uInsert == 0) + { + if (bAlreadySeparated) + { + DeleteMenu(hmDst, uInsert, MF_BYPOSITION); + } + } + else + { + if (_SHIsMenuSeparator(hmDst, uInsert-1)) + { + if (bAlreadySeparated) + { + DeleteMenu(hmDst, uInsert, MF_BYPOSITION); + } + } + else + { + if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) + { + /* Add a separator between the menus*/ + InsertMenuW(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + } + } + } + return(uIDMax); +}
10 years
1
0
0
0
[akhaldi] 65283: [SHELL32] * Move shlmenu.cpp to the wine folder. * Convert shlmenu.cpp into shlmenu.c.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 6 12:45:07 2014 New Revision: 65283 URL:
http://svn.reactos.org/svn/reactos?rev=65283&view=rev
Log: [SHELL32] * Move shlmenu.cpp to the wine folder. * Convert shlmenu.cpp into shlmenu.c. Added: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c - copied, changed from r65270, branches/shell-experiments/dll/win32/shell32/shlmenu.cpp Removed: branches/shell-experiments/dll/win32/shell32/shlmenu.cpp Modified: branches/shell-experiments/dll/win32/shell32/CMakeLists.txt Modified: branches/shell-experiments/dll/win32/shell32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/CMakeLists.txt [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/CMakeLists.txt [iso-8859-1] Thu Nov 6 12:45:07 2014 @@ -55,7 +55,6 @@ shlfileop.cpp shlfolder.cpp CFileSysBindData.cpp - shlmenu.cpp CDefView.cpp stubs.cpp systray.cpp @@ -76,6 +75,7 @@ wine/shellpath.c wine/shellreg.c wine/shellstring.c + wine/shlmenu.c wine/shpolicy.c vista.c shell32.rc Removed: branches/shell-experiments/dll/win32/shell32/shlmenu.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/shlmenu.cpp [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/shlmenu.cpp (removed) @@ -1,986 +0,0 @@ -/* - * see
www.geocities.com/SiliconValley/4942/filemenu.html
- * - * Copyright 1999, 2000 Juergen Schmied - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "precomp.h" - -WINE_DEFAULT_DEBUG_CHANNEL(shellmenu); - -#ifdef FM_SEPARATOR -#undef FM_SEPARATOR -#endif -#define FM_SEPARATOR (LPCWSTR)1 - -static BOOL FileMenu_AppendItemW(HMENU hMenu, LPCWSTR lpText, UINT uID, int icon, - HMENU hMenuPopup, int nItemHeight); - -typedef struct -{ - BOOL bInitialized; - BOOL bFixedItems; - /* create */ - COLORREF crBorderColor; - int nBorderWidth; - HBITMAP hBorderBmp; - - /* insert using pidl */ - LPITEMIDLIST pidl; - UINT uID; - UINT uFlags; - UINT uEnumFlags; - LPFNFMCALLBACK lpfnCallback; -} FMINFO, *LPFMINFO; - -typedef struct -{ int cchItemText; - int iIconIndex; - HMENU hMenu; - WCHAR szItemText[1]; -} FMITEM, * LPFMITEM; - -static BOOL bAbortInit; - -#define CCH_MAXITEMTEXT 256 - -static LPFMINFO FM_GetMenuInfo(HMENU hmenu) -{ - MENUINFO MenuInfo; - LPFMINFO menudata; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hmenu, &MenuInfo)) - return NULL; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - return menudata; - -} -/************************************************************************* - * FM_SetMenuParameter [internal] - * - */ -static LPFMINFO FM_SetMenuParameter( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - LPFMINFO menudata; - - TRACE("\n"); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree(menudata->pidl); - - menudata->uID = uID; - menudata->pidl = ILClone(pidl); - menudata->uFlags = uFlags; - menudata->uEnumFlags = uEnumFlags; - menudata->lpfnCallback = lpfnCallback; - - return menudata; -} - -/************************************************************************* - * FM_InitMenuPopup [internal] - * - */ -static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) -{ - CComPtr<IShellFolder> lpsf; - CComPtr<IShellFolder> lpsf2; - ULONG ulItemAttr = SFGAO_FOLDER; - UINT uID, uEnumFlags; - LPFNFMCALLBACK lpfnCallback; - LPCITEMIDLIST pidl; - WCHAR sTemp[MAX_PATH]; - int NumberOfItems = 0, iIcon; - MENUINFO MenuInfo; - LPFMINFO menudata; - - TRACE("%p %p\n", hmenu, pAlternatePidl); - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (!GetMenuInfo(hmenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO) MenuInfo.dwMenuData; - - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return 0; - } - - if (menudata->bInitialized) - return 0; - - pidl = (pAlternatePidl ? pAlternatePidl : menudata->pidl); - if (!pidl) - return 0; - - uID = menudata->uID; - uEnumFlags = menudata->uEnumFlags; - lpfnCallback = menudata->lpfnCallback; - menudata->bInitialized = FALSE; - - SetMenuInfo(hmenu, &MenuInfo); - - if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) - { - if (SUCCEEDED(lpsf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &lpsf2)))) - { - CComPtr<IEnumIDList> lpe; - - if (SUCCEEDED(lpsf2->EnumObjects(0, uEnumFlags, &lpe))) - { - - LPITEMIDLIST pidlTemp = NULL; - ULONG ulFetched; - - while ((!bAbortInit) && (S_OK == lpe->Next(1, &pidlTemp, &ulFetched))) - { - if (SUCCEEDED(lpsf->GetAttributesOf(1, (LPCITEMIDLIST*) &pidlTemp, &ulItemAttr))) - { - ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING); - if (!(PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon))) - iIcon = FM_BLANK_ICON; - if (SFGAO_FOLDER & ulItemAttr) - { - LPFMINFO lpFmMi; - MENUINFO MenuInfo; - HMENU hMenuPopup = CreatePopupMenu(); - - lpFmMi = (LPFMINFO) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - - lpFmMi->pidl = ILCombine(pidl, pidlTemp); - lpFmMi->uEnumFlags = SHCONTF_FOLDERS | SHCONTF_NONFOLDERS; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) lpFmMi; - SetMenuInfo(hMenuPopup, &MenuInfo); - - FileMenu_AppendItemW(hmenu, sTemp, uID, iIcon, hMenuPopup, FM_DEFAULT_HEIGHT); - } - else - { - LPWSTR pExt = PathFindExtensionW(sTemp); - if (pExt) - *pExt = 0; - FileMenu_AppendItemW(hmenu, sTemp, uID, iIcon, 0, FM_DEFAULT_HEIGHT); - } - } - - if (lpfnCallback) - { - TRACE("enter callback\n"); - lpfnCallback(pidl, pidlTemp); - TRACE("leave callback\n"); - } - - NumberOfItems++; - } - } - } - } - - if (GetMenuItemCount(hmenu) == 0) - { - static const WCHAR szEmpty [] = { '(', 'e', 'm', 'p', 't', 'y', ')', 0 }; - FileMenu_AppendItemW(hmenu, szEmpty, uID, FM_BLANK_ICON, 0, FM_DEFAULT_HEIGHT); - NumberOfItems++; - } - - menudata->bInitialized = TRUE; - SetMenuInfo(hmenu, &MenuInfo); - - return NumberOfItems; -} - -/************************************************************************* - * FileMenu_Create [SHELL32.114] - * - * NOTES - * for non-root menus values are - * (ffffffff,00000000,00000000,00000000,00000000) - */ -HMENU WINAPI FileMenu_Create ( - COLORREF crBorderColor, - int nBorderWidth, - HBITMAP hBorderBmp, - int nSelHeight, - UINT uFlags) -{ - MENUINFO MenuInfo; - LPFMINFO menudata; - - HMENU hMenu = CreatePopupMenu(); - - TRACE("0x%08x 0x%08x %p 0x%08x 0x%08x hMenu=%p\n", - crBorderColor, nBorderWidth, hBorderBmp, nSelHeight, uFlags, hMenu); - - menudata = (LPFMINFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMINFO)); - menudata->crBorderColor = crBorderColor; - menudata->nBorderWidth = nBorderWidth; - menudata->hBorderBmp = hBorderBmp; - - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - MenuInfo.dwMenuData = (ULONG_PTR) menudata; - SetMenuInfo (hMenu, &MenuInfo); - - return hMenu; -} - -/************************************************************************* - * FileMenu_Destroy [SHELL32.118] - * - * NOTES - * exported by name - */ -void WINAPI FileMenu_Destroy (HMENU hmenu) -{ - LPFMINFO menudata; - - TRACE("%p\n", hmenu); - - FileMenu_DeleteAllItems (hmenu); - - menudata = FM_GetMenuInfo(hmenu); - - SHFree( menudata->pidl); - HeapFree(GetProcessHeap(), 0, menudata); - - DestroyMenu (hmenu); -} - -/************************************************************************* - * FileMenu_AppendItem [SHELL32.115] - * - */ -static BOOL FileMenu_AppendItemW( - HMENU hMenu, - LPCWSTR lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - MENUITEMINFOW mii; - LPFMITEM myItem; - LPFMINFO menudata; - MENUINFO MenuInfo; - - - TRACE("%p %s 0x%08x 0x%08x %p 0x%08x\n", - hMenu, (lpText!=FM_SEPARATOR) ? debugstr_w(lpText) : NULL, - uID, icon, hMenuPopup, nItemHeight); - - ZeroMemory (&mii, sizeof(MENUITEMINFOW)); - - mii.cbSize = sizeof(MENUITEMINFOW); - - if (lpText != FM_SEPARATOR) - { - int len = strlenW (lpText); - myItem = (LPFMITEM)SHAlloc(sizeof(FMITEM) + len*sizeof(WCHAR)); - wcscpy (myItem->szItemText, lpText); - myItem->cchItemText = len; - myItem->iIconIndex = icon; - myItem->hMenu = hMenu; - mii.fMask = MIIM_DATA; - mii.dwItemData = (ULONG_PTR) myItem; - } - - if ( hMenuPopup ) - { /* sub menu */ - mii.fMask |= MIIM_TYPE | MIIM_SUBMENU; - mii.fType = MFT_OWNERDRAW; - mii.hSubMenu = hMenuPopup; - } - else if (lpText == FM_SEPARATOR ) - { mii.fMask |= MIIM_ID | MIIM_TYPE; - mii.fType = MFT_SEPARATOR; - } - else - { /* normal item */ - mii.fMask |= MIIM_ID | MIIM_TYPE | MIIM_STATE; - mii.fState = MFS_ENABLED | MFS_DEFAULT; - mii.fType = MFT_OWNERDRAW; - } - mii.wID = uID; - - InsertMenuItemW (hMenu, (UINT)-1, TRUE, &mii); - - /* set bFixedItems to true */ - MenuInfo.cbSize = sizeof(MENUINFO); - MenuInfo.fMask = MIM_MENUDATA; - - if (! GetMenuInfo(hMenu, &MenuInfo)) - return FALSE; - - menudata = (LPFMINFO)MenuInfo.dwMenuData; - if ((menudata == 0) || (MenuInfo.cbSize != sizeof(MENUINFO))) - { - ERR("menudata corrupt: %p %u\n", menudata, MenuInfo.cbSize); - return FALSE; - } - - menudata->bFixedItems = TRUE; - SetMenuInfo(hMenu, &MenuInfo); - - return TRUE; - -} - -/**********************************************************************/ - -EXTERN_C BOOL WINAPI FileMenu_AppendItemAW( - HMENU hMenu, - LPCVOID lpText, - UINT uID, - int icon, - HMENU hMenuPopup, - int nItemHeight) -{ - BOOL ret; - - if (!lpText) return FALSE; - - if (SHELL_OsIsUnicode() || lpText == FM_SEPARATOR) - ret = FileMenu_AppendItemW(hMenu, (LPWSTR)lpText, uID, icon, hMenuPopup, nItemHeight); - else - { - DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, NULL, 0 ); - LPWSTR lpszText = (LPWSTR)HeapAlloc ( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - if (!lpszText) return FALSE; - MultiByteToWideChar( CP_ACP, 0, (LPSTR)lpText, -1, lpszText, len ); - ret = FileMenu_AppendItemW(hMenu, lpszText, uID, icon, hMenuPopup, nItemHeight); - HeapFree( GetProcessHeap(), 0, lpszText ); - } - - return ret; -} - -/************************************************************************* - * FileMenu_InsertUsingPidl [SHELL32.110] - * - * NOTES - * uEnumFlags any SHCONTF flag - */ -int WINAPI FileMenu_InsertUsingPidl ( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - pdump (pidl); - - bAbortInit = FALSE; - - FM_SetMenuParameter(hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_ReplaceUsingPidl [SHELL32.113] - * - * FIXME: the static items are deleted but won't be refreshed - */ -int WINAPI FileMenu_ReplaceUsingPidl( - HMENU hmenu, - UINT uID, - LPCITEMIDLIST pidl, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x %p 0x%08x %p\n", - hmenu, uID, pidl, uEnumFlags, lpfnCallback); - - FileMenu_DeleteAllItems (hmenu); - - FM_SetMenuParameter(hmenu, uID, pidl, 0, uEnumFlags, lpfnCallback); - - return FM_InitMenuPopup(hmenu, NULL); -} - -/************************************************************************* - * FileMenu_Invalidate [SHELL32.111] - */ -void WINAPI FileMenu_Invalidate (HMENU hMenu) -{ - FIXME("%p\n",hMenu); -} - -/************************************************************************* - * FileMenu_FindSubMenuByPidl [SHELL32.106] - */ -HMENU WINAPI FileMenu_FindSubMenuByPidl( - HMENU hMenu, - LPCITEMIDLIST pidl) -{ - FIXME("%p %p\n",hMenu, pidl); - return 0; -} - -/************************************************************************* - * FileMenu_AppendFilesForPidl [SHELL32.124] - */ -int WINAPI FileMenu_AppendFilesForPidl( - HMENU hmenu, - LPCITEMIDLIST pidl, - BOOL bAddSeparator) -{ - LPFMINFO menudata; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - FM_InitMenuPopup(hmenu, pidl); - - if (bAddSeparator) - FileMenu_AppendItemW (hmenu, FM_SEPARATOR, 0, 0, 0, FM_DEFAULT_HEIGHT); - - TRACE("%p %p 0x%08x\n",hmenu, pidl,bAddSeparator); - - return 0; -} -/************************************************************************* - * FileMenu_AddFilesForPidl [SHELL32.125] - * - * NOTES - * uEnumFlags any SHCONTF flag - */ -int WINAPI FileMenu_AddFilesForPidl ( - HMENU hmenu, - UINT uReserved, - UINT uID, - LPCITEMIDLIST pidl, - UINT uFlags, - UINT uEnumFlags, - LPFNFMCALLBACK lpfnCallback) -{ - TRACE("%p 0x%08x 0x%08x %p 0x%08x 0x%08x %p\n", - hmenu, uReserved, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - - return FileMenu_InsertUsingPidl ( hmenu, uID, pidl, uFlags, uEnumFlags, lpfnCallback); - -} - - -/************************************************************************* - * FileMenu_TrackPopupMenuEx [SHELL32.116] - */ -BOOL WINAPI FileMenu_TrackPopupMenuEx ( - HMENU hMenu, - UINT uFlags, - int x, - int y, - HWND hWnd, - LPTPMPARAMS lptpm) -{ - TRACE("%p 0x%08x 0x%x 0x%x %p %p\n", - hMenu, uFlags, x, y, hWnd, lptpm); - return TrackPopupMenuEx(hMenu, uFlags, x, y, hWnd, lptpm); -} - -/************************************************************************* - * FileMenu_GetLastSelectedItemPidls [SHELL32.107] - */ -BOOL WINAPI FileMenu_GetLastSelectedItemPidls( - UINT uReserved, - LPCITEMIDLIST *ppidlFolder, - LPCITEMIDLIST *ppidlItem) -{ - FIXME("0x%08x %p %p\n",uReserved, ppidlFolder, ppidlItem); - return FALSE; -} - -#define FM_ICON_SIZE 16 -#define FM_Y_SPACE 4 -#define FM_SPACE1 4 -#define FM_SPACE2 2 -#define FM_LEFTBORDER 2 -#define FM_RIGHTBORDER 8 -/************************************************************************* - * FileMenu_MeasureItem [SHELL32.112] - */ -LRESULT WINAPI FileMenu_MeasureItem( - HWND hWnd, - LPMEASUREITEMSTRUCT lpmis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpmis->itemData); - HDC hdc = GetDC(hWnd); - SIZE size; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpmis, debugstr_w(pMyItem->szItemText)); - - GetTextExtentPoint32W(hdc, pMyItem->szItemText, pMyItem->cchItemText, &size); - - lpmis->itemWidth = size.cx + FM_LEFTBORDER + FM_ICON_SIZE + FM_SPACE1 + FM_SPACE2 + FM_RIGHTBORDER; - lpmis->itemHeight = (size.cy > (FM_ICON_SIZE + FM_Y_SPACE)) ? size.cy : (FM_ICON_SIZE + FM_Y_SPACE); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - lpmis->itemWidth += menuinfo->nBorderWidth; - - TRACE("-- 0x%04x 0x%04x\n", lpmis->itemWidth, lpmis->itemHeight); - ReleaseDC (hWnd, hdc); - return 0; -} -/************************************************************************* - * FileMenu_DrawItem [SHELL32.105] - */ -LRESULT WINAPI FileMenu_DrawItem( - HWND hWnd, - LPDRAWITEMSTRUCT lpdis) -{ - LPFMITEM pMyItem = (LPFMITEM)(lpdis->itemData); - COLORREF clrPrevText, clrPrevBkgnd; - int xi,yi,xt,yt; - HIMAGELIST hImageList; - RECT TextRect; - LPFMINFO menuinfo; - - TRACE("%p %p %s\n", hWnd, lpdis, debugstr_w(pMyItem->szItemText)); - - if (lpdis->itemState & ODS_SELECTED) - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHTTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_HIGHLIGHT)); - } - else - { - clrPrevText = SetTextColor(lpdis->hDC, GetSysColor (COLOR_MENUTEXT)); - clrPrevBkgnd = SetBkColor(lpdis->hDC, GetSysColor (COLOR_MENU)); - } - - CopyRect(&TextRect, &(lpdis->rcItem)); - - /* add the menubitmap */ - menuinfo = FM_GetMenuInfo(pMyItem->hMenu); - if (menuinfo->nBorderWidth) - TextRect.left += menuinfo->nBorderWidth; - - TextRect.left += FM_LEFTBORDER; - xi = TextRect.left + FM_SPACE1; - yi = TextRect.top + FM_Y_SPACE/2; - TextRect.bottom -= FM_Y_SPACE/2; - - xt = xi + FM_ICON_SIZE + FM_SPACE2; - yt = yi; - - ExtTextOutW (lpdis->hDC, xt , yt, ETO_OPAQUE, &TextRect, pMyItem->szItemText, pMyItem->cchItemText, NULL); - - Shell_GetImageLists(0, &hImageList); - ImageList_Draw(hImageList, pMyItem->iIconIndex, lpdis->hDC, xi, yi, ILD_NORMAL); - - TRACE("-- 0x%04x 0x%04x 0x%04x 0x%04x\n", TextRect.left, TextRect.top, TextRect.right, TextRect.bottom); - - SetTextColor(lpdis->hDC, clrPrevText); - SetBkColor(lpdis->hDC, clrPrevBkgnd); - - return TRUE; -} - -/************************************************************************* - * FileMenu_InitMenuPopup [SHELL32.109] - * - * NOTES - * The filemenu is an ownerdrawn menu. Call this function responding to - * WM_INITPOPUPMENU - * - */ -BOOL WINAPI FileMenu_InitMenuPopup (HMENU hmenu) -{ - FM_InitMenuPopup(hmenu, NULL); - return TRUE; -} - -/************************************************************************* - * FileMenu_HandleMenuChar [SHELL32.108] - */ -LRESULT WINAPI FileMenu_HandleMenuChar( - HMENU hMenu, - WPARAM wParam) -{ - FIXME("%p 0x%08lx\n",hMenu,wParam); - return 0; -} - -/************************************************************************* - * FileMenu_DeleteAllItems [SHELL32.104] - * - * NOTES - * exported by name - */ -BOOL WINAPI FileMenu_DeleteAllItems (HMENU hmenu) -{ - MENUITEMINFOW mii; - LPFMINFO menudata; - - int i; - - TRACE("%p\n", hmenu); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU|MIIM_DATA; - - for (i = 0; i < GetMenuItemCount( hmenu ); i++) - { GetMenuItemInfoW(hmenu, i, TRUE, &mii ); - - SHFree((LPFMINFO)mii.dwItemData); - - if (mii.hSubMenu) - FileMenu_Destroy(mii.hSubMenu); - } - - while (DeleteMenu (hmenu, 0, MF_BYPOSITION)){}; - - menudata = FM_GetMenuInfo(hmenu); - - menudata->bInitialized = FALSE; - - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByCmd [SHELL32.117] - * - */ -BOOL WINAPI FileMenu_DeleteItemByCmd (HMENU hMenu, UINT uID) -{ - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uID); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uID, FALSE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYCOMMAND, uID); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByIndex [SHELL32.140] - */ -BOOL WINAPI FileMenu_DeleteItemByIndex ( HMENU hMenu, UINT uPos) -{ - MENUITEMINFOW mii; - - TRACE("%p 0x%08x\n", hMenu, uPos); - - ZeroMemory ( &mii, sizeof(MENUITEMINFOW)); - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_SUBMENU; - - GetMenuItemInfoW(hMenu, uPos, TRUE, &mii ); - if ( mii.hSubMenu ) - { - /* FIXME: Do what? */ - } - - DeleteMenu(hMenu, MF_BYPOSITION, uPos); - return TRUE; -} - -/************************************************************************* - * FileMenu_DeleteItemByFirstID [SHELL32.141] - */ -EXTERN_C BOOL WINAPI FileMenu_DeleteItemByFirstID( - HMENU hMenu, - UINT uID) -{ - TRACE("%p 0x%08x\n", hMenu, uID); - return FALSE; -} - -/************************************************************************* - * FileMenu_DeleteSeparator [SHELL32.142] - */ -BOOL WINAPI FileMenu_DeleteSeparator(HMENU hMenu) -{ - TRACE("%p\n", hMenu); - return FALSE; -} - -/************************************************************************* - * FileMenu_EnableItemByCmd [SHELL32.143] - */ -BOOL WINAPI FileMenu_EnableItemByCmd( - HMENU hMenu, - UINT uID, - BOOL bEnable) -{ - TRACE("%p 0x%08x 0x%08x\n", hMenu, uID,bEnable); - return FALSE; -} - -/************************************************************************* - * FileMenu_GetItemExtent [SHELL32.144] - * - * NOTES - * if the menu is too big, entries are getting cut away!! - */ -DWORD WINAPI FileMenu_GetItemExtent (HMENU hMenu, UINT uPos) -{ RECT rect; - - FIXME("%p 0x%08x\n", hMenu, uPos); - - if (GetMenuItemRect(0, hMenu, uPos, &rect)) - { FIXME("0x%04x 0x%04x 0x%04x 0x%04x\n", - rect.right, rect.left, rect.top, rect.bottom); - return ((rect.right-rect.left)<<16) + (rect.top-rect.bottom); - } - return 0x00100010; /*FIXME*/ -} - -/************************************************************************* - * FileMenu_AbortInitMenu [SHELL32.120] - * - */ -void WINAPI FileMenu_AbortInitMenu (void) -{ TRACE("\n"); - bAbortInit = TRUE; -} - -/************************************************************************* - * SHFind_InitMenuPopup [SHELL32.149] - * - * Get the IContextMenu instance for the submenu of options displayed - * for the Search entry in the Classic style Start menu. - * - * PARAMETERS - * hMenu [in] handle of menu previously created - * hWndParent [in] parent window - * w [in] no pointer (0x209 over here) perhaps menu IDs ??? - * x [in] no pointer (0x226 over here) - * - * RETURNS - * LPXXXXX pointer to struct containing a func addr at offset 8 - * or NULL at failure. - */ -EXTERN_C IContextMenu * WINAPI SHFind_InitMenuPopup (HMENU hMenu, HWND hWndParent, UINT w, UINT x) -{ - FIXME("hmenu=%p hwnd=%p 0x%08x 0x%08x stub\n", - hMenu,hWndParent,w,x); - return NULL; /* this is supposed to be a pointer */ -} - -/************************************************************************* - * _SHIsMenuSeparator (internal) - */ -static BOOL _SHIsMenuSeparator(HMENU hm, int i) -{ - MENUITEMINFOW mii; - - mii.cbSize = sizeof(MENUITEMINFOW); - mii.fMask = MIIM_TYPE; - mii.cch = 0; /* WARNING: We MUST initialize it to 0*/ - if (!GetMenuItemInfoW(hm, i, TRUE, &mii)) - { - return(FALSE); - } - - if (mii.fType & MFT_SEPARATOR) - { - return(TRUE); - } - - return(FALSE); -} - -/************************************************************************* - * Shell_MergeMenus [SHELL32.67] - */ -UINT WINAPI Shell_MergeMenus (HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags) -{ - int nItem; - HMENU hmSubMenu; - BOOL bAlreadySeparated; - MENUITEMINFOW miiSrc; - WCHAR szName[256]; - UINT uTemp, uIDMax = uIDAdjust; - - TRACE("hmenu1=%p hmenu2=%p 0x%04x 0x%04x 0x%04x 0x%04x\n", - hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags); - - if (!hmDst || !hmSrc) - return uIDMax; - - nItem = GetMenuItemCount(hmDst); - if (nItem == -1) - return uIDMax; - - if (uInsert >= (UINT)nItem) /* insert position inside menu? */ - { - uInsert = (UINT)nItem; /* append on the end */ - bAlreadySeparated = TRUE; - } - else - { - bAlreadySeparated = _SHIsMenuSeparator(hmDst, uInsert); - } - - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus */ - InsertMenuA(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - bAlreadySeparated = TRUE; - } - - - /* Go through the menu items and clone them*/ - for (nItem = GetMenuItemCount(hmSrc) - 1; nItem >= 0; nItem--) - { - miiSrc.cbSize = sizeof(MENUITEMINFOW); - miiSrc.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS | MIIM_TYPE | MIIM_DATA; - - /* We need to reset this every time through the loop in case menus DON'T have IDs*/ - miiSrc.fType = MFT_STRING; - miiSrc.dwTypeData = szName; - miiSrc.dwItemData = 0; - miiSrc.cch = sizeof(szName)/sizeof(WCHAR); - - if (!GetMenuItemInfoW(hmSrc, nItem, TRUE, &miiSrc)) - { - continue; - } - -/* TRACE("found menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmSrc, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); -*/ - if (miiSrc.fType & MFT_SEPARATOR) - { - /* This is a separator; don't put two of them in a row */ - if (bAlreadySeparated) - continue; - - bAlreadySeparated = TRUE; - } - else if (miiSrc.hSubMenu) - { - if (uFlags & MM_SUBMENUSHAVEIDS) - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - } - else - { - miiSrc.fMask &= ~MIIM_ID; /* Don't set IDs for submenus that didn't have them already */ - } - hmSubMenu = miiSrc.hSubMenu; - - miiSrc.hSubMenu = CreatePopupMenu(); - - if (!miiSrc.hSubMenu) return(uIDMax); - - uTemp = Shell_MergeMenus(miiSrc.hSubMenu, hmSubMenu, 0, uIDAdjust, uIDAdjustMax, uFlags & MM_SUBMENUSHAVEIDS); - - if (uIDMax <= uTemp) - uIDMax = uTemp; - - bAlreadySeparated = FALSE; - } - else /* normal menu item */ - { - miiSrc.wID += uIDAdjust; /* add uIDAdjust to the ID */ - - if (miiSrc.wID > uIDAdjustMax) /* skip IDs higher than uIDAdjustMax */ - continue; - - if (uIDMax <= miiSrc.wID) /* remember the highest ID */ - uIDMax = miiSrc.wID + 1; - - bAlreadySeparated = FALSE; - } - -/* TRACE("inserting menu=0x%04x %s id=0x%04x mask=0x%08x smenu=0x%04x\n", hmDst, debugstr_a(miiSrc.dwTypeData), miiSrc.wID, miiSrc.fMask, miiSrc.hSubMenu); -*/ - if (!InsertMenuItemW(hmDst, uInsert, TRUE, &miiSrc)) - { - return(uIDMax); - } - } - - /* Ensure the correct number of separators at the beginning of the - inserted menu items*/ - if (uInsert == 0) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if (_SHIsMenuSeparator(hmDst, uInsert-1)) - { - if (bAlreadySeparated) - { - DeleteMenu(hmDst, uInsert, MF_BYPOSITION); - } - } - else - { - if ((uFlags & MM_ADDSEPARATOR) && !bAlreadySeparated) - { - /* Add a separator between the menus*/ - InsertMenuW(hmDst, uInsert, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - } - } - } - return(uIDMax); -} Copied: branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c (from r65270, branches/shell-experiments/dll/win32/shell32/shlmenu.cpp) URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/shlmenu.cpp [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/wine/shlmenu.c [iso-8859-1] Thu Nov 6 12:45:07 2014 @@ -18,7 +18,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "precomp.h" +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COBJMACROS + +#include <windef.h> +#include <winbase.h> +#include <shlobj.h> +#include <undocshell.h> +#include <shlwapi.h> +#include <wine/debug.h> +#include <wine/unicode.h> + +#include "pidl.h" +#include "shell32_main.h" WINE_DEFAULT_DEBUG_CHANNEL(shellmenu); @@ -115,8 +128,8 @@ */ static int FM_InitMenuPopup(HMENU hmenu, LPCITEMIDLIST pAlternatePidl) { - CComPtr<IShellFolder> lpsf; - CComPtr<IShellFolder> lpsf2; + IShellFolder *lpsf; + IShellFolder *lpsf2; ULONG ulItemAttr = SFGAO_FOLDER; UINT uID, uEnumFlags; LPFNFMCALLBACK lpfnCallback; @@ -158,19 +171,19 @@ if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) { - if (SUCCEEDED(lpsf->BindToObject(pidl, 0, IID_PPV_ARG(IShellFolder, &lpsf2)))) + if (SUCCEEDED(IShellFolder_BindToObject(lpsf, pidl,0,&IID_IShellFolder,(LPVOID *)&lpsf2))) { - CComPtr<IEnumIDList> lpe; - - if (SUCCEEDED(lpsf2->EnumObjects(0, uEnumFlags, &lpe))) + IEnumIDList *lpe; + + if (SUCCEEDED (IShellFolder_EnumObjects(lpsf2, 0, uEnumFlags, &lpe ))) { LPITEMIDLIST pidlTemp = NULL; ULONG ulFetched; - while ((!bAbortInit) && (S_OK == lpe->Next(1, &pidlTemp, &ulFetched))) + while ((!bAbortInit) && (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))) { - if (SUCCEEDED(lpsf->GetAttributesOf(1, (LPCITEMIDLIST*) &pidlTemp, &ulItemAttr))) + if (SUCCEEDED (IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulItemAttr))) { ILGetDisplayNameExW(NULL, pidlTemp, sTemp, ILGDN_FORPARSING); if (!(PidlToSicIndex(lpsf, pidlTemp, FALSE, 0, &iIcon)))
10 years
1
0
0
0
[akhaldi] 65282: [SHELL32] * Apply Wine commit bfad4fa9 by Piotr Caban: Don't convert output parameter in SHBrowseForFolderA (Valgrind). CORE-8540
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 6 11:25:43 2014 New Revision: 65282 URL:
http://svn.reactos.org/svn/reactos?rev=65282&view=rev
Log: [SHELL32] * Apply Wine commit bfad4fa9 by Piotr Caban: Don't convert output parameter in SHBrowseForFolderA (Valgrind). CORE-8540 Modified: branches/shell-experiments/dll/win32/shell32/wine/brsfolder.c Modified: branches/shell-experiments/dll/win32/shell32/wine/brsfolder.c URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
============================================================================== --- branches/shell-experiments/dll/win32/shell32/wine/brsfolder.c [iso-8859-1] (original) +++ branches/shell-experiments/dll/win32/shell32/wine/brsfolder.c [iso-8859-1] Thu Nov 6 11:25:43 2014 @@ -1073,10 +1073,7 @@ bi.hwndOwner = lpbi->hwndOwner; bi.pidlRoot = lpbi->pidlRoot; if (lpbi->pszDisplayName) - { bi.pszDisplayName = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, lpbi->pszDisplayName, -1, bi.pszDisplayName, MAX_PATH ); - } else bi.pszDisplayName = NULL;
10 years
1
0
0
0
[aandrejevic] 65281: [FAST486] We can't load the stack segment until after we've updated the CPL.
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Thu Nov 6 05:37:50 2014 New Revision: 65281 URL:
http://svn.reactos.org/svn/reactos?rev=65281&view=rev
Log: [FAST486] We can't load the stack segment until after we've updated the CPL. Modified: trunk/reactos/lib/fast486/opcodes.c Modified: trunk/reactos/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=…
============================================================================== --- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Thu Nov 6 05:37:50 2014 @@ -4496,7 +4496,13 @@ /* Exception */ return; } - + } + + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(Segment); + + if (State->Cpl > OldCpl) + { /* Load new SS */ if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) { @@ -4507,13 +4513,7 @@ /* Set ESP */ if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); - } - - /* Update the CPL */ - State->Cpl = GET_SEGMENT_RPL(Segment); - - if (State->Cpl > OldCpl) - { + /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) { @@ -4732,7 +4732,22 @@ /* Exception */ return; } - + } + + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(CodeSel); + + /* Set the new flags */ + if (Size) State->Flags.Long = NewFlags.Long & PROT_MODE_FLAGS_MASK; + else State->Flags.LowWord = NewFlags.LowWord & PROT_MODE_FLAGS_MASK; + State->Flags.AlwaysSet = TRUE; + + /* Set additional flags */ + if (OldCpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; + if (OldCpl == 0) State->Flags.Iopl = NewFlags.Iopl; + + if (State->Cpl > OldCpl) + { /* Load new SS */ if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) { @@ -4743,22 +4758,7 @@ /* Set ESP */ if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); - } - - /* Update the CPL */ - State->Cpl = GET_SEGMENT_RPL(CodeSel); - - /* Set the new flags */ - if (Size) State->Flags.Long = NewFlags.Long & PROT_MODE_FLAGS_MASK; - else State->Flags.LowWord = NewFlags.LowWord & PROT_MODE_FLAGS_MASK; - State->Flags.AlwaysSet = TRUE; - - /* Set additional flags */ - if (OldCpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; - if (OldCpl == 0) State->Flags.Iopl = NewFlags.Iopl; - - if (State->Cpl > OldCpl) - { + /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) {
10 years
1
0
0
0
[aandrejevic] 65280: [FAST486] Fix the limit calculation when using page granularity. RETF can also perform inter-privilege returns. Fix the privilege checks when loading CS. DPL != CPL is only a #...
by aandrejevic@svn.reactos.org
Author: aandrejevic Date: Thu Nov 6 05:16:14 2014 New Revision: 65280 URL:
http://svn.reactos.org/svn/reactos?rev=65280&view=rev
Log: [FAST486] Fix the limit calculation when using page granularity. RETF can also perform inter-privilege returns. Fix the privilege checks when loading CS. DPL != CPL is only a #GP when we're doing a jump or a call. Modified: trunk/reactos/lib/fast486/common.c trunk/reactos/lib/fast486/common.inl trunk/reactos/lib/fast486/extraops.c trunk/reactos/lib/fast486/opcodes.c trunk/reactos/lib/fast486/opgroups.c Modified: trunk/reactos/lib/fast486/common.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.c?rev=6…
============================================================================== --- trunk/reactos/lib/fast486/common.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/common.c [iso-8859-1] Thu Nov 6 05:16:14 2014 @@ -553,7 +553,12 @@ /* Calculate the limit of the new TSS */ NewTssLimit = NewTssDescriptor.Limit | (NewTssDescriptor.LimitHigh << 16); - if (NewTssDescriptor.Granularity) NewTssLimit <<= 12; + + if (NewTssDescriptor.Granularity) + { + NewTssLimit <<= 12; + NewTssLimit |= 0x00000FFF; + } if (NewTssLimit < sizeof(FAST486_TSS)) { @@ -739,7 +744,12 @@ State->Ldtr.Selector = NewTss.Ldtr; State->Ldtr.Base = GdtEntry.Base | (GdtEntry.BaseMid << 16) | (GdtEntry.BaseHigh << 24); State->Ldtr.Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); - if (GdtEntry.Granularity) State->Ldtr.Limit <<= 12; + + if (GdtEntry.Granularity) + { + State->Ldtr.Limit <<= 12; + State->Ldtr.Limit |= 0x00000FFF; + } } else { Modified: trunk/reactos/lib/fast486/common.inl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/common.inl?rev…
============================================================================== --- trunk/reactos/lib/fast486/common.inl [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/common.inl [iso-8859-1] Thu Nov 6 05:16:14 2014 @@ -594,16 +594,12 @@ { /* Regular code segment */ - if ((GET_SEGMENT_RPL(Selector) > Fast486GetCurrentPrivLevel(State)) - || (Fast486GetCurrentPrivLevel(State) != GdtEntry.Dpl)) + if ((GET_SEGMENT_RPL(Selector) < Fast486GetCurrentPrivLevel(State))) { Fast486ExceptionWithErrorCode(State, Exception, Selector); return FALSE; } } - - /* Update CPL */ - State->Cpl = GET_SEGMENT_RPL(Selector); } else { @@ -653,7 +649,11 @@ CachedDescriptor->Size = GdtEntry.Size; /* Check for page granularity */ - if (GdtEntry.Granularity) CachedDescriptor->Limit <<= 12; + if (GdtEntry.Granularity) + { + CachedDescriptor->Limit <<= 12; + CachedDescriptor->Limit |= 0x00000FFF; + } } else { @@ -730,6 +730,13 @@ default: { + /* Security check for jumps and calls only */ + if (State->Cpl != Descriptor.Dpl) + { + Fast486ExceptionWithErrorCode(State, FAST486_EXCEPTION_GP, Selector); + return FALSE; + } + return TRUE; } } Modified: trunk/reactos/lib/fast486/extraops.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/extraops.c?rev…
============================================================================== --- trunk/reactos/lib/fast486/extraops.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/extraops.c [iso-8859-1] Thu Nov 6 05:16:14 2014 @@ -475,7 +475,12 @@ /* Calculate the limit */ Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); - if (GdtEntry.Granularity) Limit <<= 12; + + if (GdtEntry.Granularity) + { + Limit <<= 12; + Limit |= 0x00000FFF; + } /* Set ZF */ State->Flags.Zf = TRUE; Modified: trunk/reactos/lib/fast486/opcodes.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opcodes.c?rev=…
============================================================================== --- trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/opcodes.c [iso-8859-1] Thu Nov 6 05:16:14 2014 @@ -4474,6 +4474,63 @@ return; } + if ((State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) && !State->Flags.Vm) + { + INT i; + INT OldCpl = Fast486GetCurrentPrivLevel(State); + ULONG StackPtr; + ULONG StackSel; + + if (GET_SEGMENT_RPL(Segment) > OldCpl) + { + /* Pop ESP */ + if (!Fast486StackPop(State, &StackPtr)) + { + /* Exception */ + return; + } + + /* Pop SS */ + if (!Fast486StackPop(State, &StackSel)) + { + /* Exception */ + return; + } + + /* Load new SS */ + if (!Fast486LoadSegment(State, FAST486_REG_SS, StackSel)) + { + /* Exception */ + return; + } + + /* Set ESP */ + if (Size) State->GeneralRegs[FAST486_REG_ESP].Long = StackPtr; + else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); + } + + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(Segment); + + if (State->Cpl > OldCpl) + { + /* Check segment security */ + for (i = 0; i < FAST486_NUM_SEG_REGS; i++) + { + /* Don't check CS or SS */ + if ((i == FAST486_REG_CS) || (i == FAST486_REG_SS)) continue; + + if ((State->Cpl > State->SegmentRegs[i].Dpl) + && (!State->SegmentRegs[i].Executable + || !State->SegmentRegs[i].DirConf)) + { + /* Load the NULL descriptor in the segment */ + if (!Fast486LoadSegment(State, i, 0)) return; + } + } + } + } + /* Load new (E)IP, and if necessary, pop the parameters */ if (Size) { @@ -4582,7 +4639,7 @@ /* Check for protected mode */ if (State->ControlRegisters[FAST486_REG_CR0] & FAST486_CR0_PE) { - INT Cpl = Fast486GetCurrentPrivLevel(State); + INT OldCpl = Fast486GetCurrentPrivLevel(State); if (State->Flags.Vm) { @@ -4660,7 +4717,7 @@ if (Size) State->InstPtr.Long = InstPtr; else State->InstPtr.LowWord = LOWORD(InstPtr); - if (GET_SEGMENT_RPL(CodeSel) > Cpl) + if (GET_SEGMENT_RPL(CodeSel) > OldCpl) { /* Pop ESP */ if (!Fast486StackPop(State, &StackPtr)) @@ -4688,27 +4745,27 @@ else State->GeneralRegs[FAST486_REG_ESP].LowWord = LOWORD(StackPtr); } + /* Update the CPL */ + State->Cpl = GET_SEGMENT_RPL(CodeSel); + /* Set the new flags */ if (Size) State->Flags.Long = NewFlags.Long & PROT_MODE_FLAGS_MASK; else State->Flags.LowWord = NewFlags.LowWord & PROT_MODE_FLAGS_MASK; State->Flags.AlwaysSet = TRUE; /* Set additional flags */ - if (Cpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; - if (Cpl == 0) State->Flags.Iopl = NewFlags.Iopl; - - if (GET_SEGMENT_RPL(CodeSel) > Cpl) - { - /* Update the CPL */ - Cpl = Fast486GetCurrentPrivLevel(State); - + if (OldCpl <= State->Flags.Iopl) State->Flags.If = NewFlags.If; + if (OldCpl == 0) State->Flags.Iopl = NewFlags.Iopl; + + if (State->Cpl > OldCpl) + { /* Check segment security */ for (i = 0; i < FAST486_NUM_SEG_REGS; i++) { /* Don't check CS or SS */ if ((i == FAST486_REG_CS) || (i == FAST486_REG_SS)) continue; - if ((Cpl > State->SegmentRegs[i].Dpl) + if ((State->Cpl > State->SegmentRegs[i].Dpl) && (!State->SegmentRegs[i].Executable || !State->SegmentRegs[i].DirConf)) { Modified: trunk/reactos/lib/fast486/opgroups.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/fast486/opgroups.c?rev…
============================================================================== --- trunk/reactos/lib/fast486/opgroups.c [iso-8859-1] (original) +++ trunk/reactos/lib/fast486/opgroups.c [iso-8859-1] Thu Nov 6 05:16:14 2014 @@ -1804,7 +1804,12 @@ State->Ldtr.Selector = Selector; State->Ldtr.Base = GdtEntry.Base | (GdtEntry.BaseMid << 16) | (GdtEntry.BaseHigh << 24); State->Ldtr.Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); - if (GdtEntry.Granularity) State->Ldtr.Limit <<= 12; + + if (GdtEntry.Granularity) + { + State->Ldtr.Limit <<= 12; + State->Ldtr.Limit |= 0x00000FFF; + } break; } @@ -1886,7 +1891,12 @@ State->TaskReg.Selector = Selector; State->TaskReg.Base = GdtEntry.Base | (GdtEntry.BaseMid << 16) | (GdtEntry.BaseHigh << 24); State->TaskReg.Limit = GdtEntry.Limit | (GdtEntry.LimitHigh << 16); - if (GdtEntry.Granularity) State->TaskReg.Limit <<= 12; + + if (GdtEntry.Granularity) + { + State->TaskReg.Limit <<= 12; + State->TaskReg.Limit |= 0x00000FFF; + } break; }
10 years
1
0
0
0
[dquintana] 65279: [EXPLORER-NEW] * Use IContextMenu for the context menus, instead of a struct with function pointers.
by dquintana@svn.reactos.org
Author: dquintana Date: Thu Nov 6 03:05:33 2014 New Revision: 65279 URL:
http://svn.reactos.org/svn/reactos?rev=65279&view=rev
Log: [EXPLORER-NEW] * Use IContextMenu for the context menus, instead of a struct with function pointers. Modified: branches/shell-experiments/base/shell/explorer-new/precomp.h branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp branches/shell-experiments/base/shell/explorer-new/traywnd.cpp Modified: branches/shell-experiments/base/shell/explorer-new/precomp.h URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
============================================================================== --- branches/shell-experiments/base/shell/explorer-new/precomp.h [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/explorer-new/precomp.h [iso-8859-1] Thu Nov 6 03:05:33 2014 @@ -155,20 +155,6 @@ #define TWM_OPENSTARTMENU (WM_USER + 260) -typedef HMENU(*PCREATECTXMENU)(IN HWND hWndOwner, - IN PVOID *ppcmContext, - IN PVOID Context OPTIONAL); -typedef VOID(*PCTXMENUCOMMAND)(IN HWND hWndOwner, - IN UINT uiCmdId, - IN PVOID pcmContext OPTIONAL, - IN PVOID Context OPTIONAL); - -typedef struct _TRAYWINDOW_CTXMENU -{ - PCREATECTXMENU CreateCtxMenu; - PCTXMENUCOMMAND CtxMenuCommand; -} TRAYWINDOW_CTXMENU, *PTRAYWINDOW_CTXMENU; - extern const GUID IID_IShellDesktopTray; #define INTERFACE ITrayWindow @@ -343,7 +329,7 @@ * startmnu.cpp */ -extern const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu; +HRESULT StartMenuBtnCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu); #define INTERFACE IStartMenuSite DECLARE_INTERFACE_(IStartMenuSite, IUnknown) Modified: branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
============================================================================== --- branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/explorer-new/startctxmnu.cpp [iso-8859-1] Thu Nov 6 03:05:33 2014 @@ -24,240 +24,222 @@ * Start menu button context menu */ -// TODO: Convert into an IContextMenu - -typedef struct _STARTMNU_CTMENU_CTX +class CStartMenuBtnCtxMenu : + public CComCoClass<CStartMenuBtnCtxMenu>, + public CComObjectRootEx<CComMultiThreadModelNoCS>, + public IContextMenu { - IContextMenu *pcm; + HWND hWndOwner; + CComPtr<ITrayWindow> TrayWnd; + CComPtr<IContextMenu> pcm; + CComPtr<IShellFolder> psf; LPITEMIDLIST pidl; -} STARTMNU_CTMENU_CTX, *PSTARTMNU_CTMENU_CTX; - -static HMENU -CreateStartContextMenu(IN HWND hWndOwner, - IN PVOID *ppcmContext, - IN PVOID Context OPTIONAL); - -static VOID -OnStartContextMenuCommand(IN HWND hWndOwner, - IN UINT uiCmdId, - IN PVOID pcmContext OPTIONAL, - IN PVOID Context OPTIONAL); - -const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu = { - CreateStartContextMenu, - OnStartContextMenuCommand + + HRESULT CreateContextMenuFromShellFolderPidl(HMENU hPopup) + { + CComPtr<IContextMenu> pcm; + HRESULT hRet; + + hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *) &pidl, IID_NULL_PPV_ARG(IContextMenu, &pcm)); + if (SUCCEEDED(hRet)) + { + if (hPopup != NULL) + { + hRet = pcm->QueryContextMenu( + hPopup, + 0, + ID_SHELL_CMD_FIRST, + ID_SHELL_CMD_LAST, + CMF_VERBSONLY); + + if (SUCCEEDED(hRet)) + { + return hRet; + } + + DestroyMenu(hPopup); + } + } + + return E_FAIL; + } + + VOID AddStartContextMenuItems(IN HMENU hPopup) + { + WCHAR szBuf[MAX_PATH]; + HRESULT hRet; + + /* Add the "Open All Users" menu item */ + if (LoadString(hExplorerInstance, + IDS_PROPERTIES, + szBuf, + sizeof(szBuf) / sizeof(szBuf[0]))) + { + AppendMenu(hPopup, + MF_STRING, + ID_SHELL_CMD_PROPERTIES, + szBuf); + } + + if (!SHRestricted(REST_NOCOMMONGROUPS)) + { + /* Check if we should add menu items for the common start menu */ + hRet = SHGetFolderPath(hWndOwner, + CSIDL_COMMON_STARTMENU, + NULL, + SHGFP_TYPE_CURRENT, + szBuf); + if (SUCCEEDED(hRet) && hRet != S_FALSE) + { + /* The directory exists, but only show the items if the + user can actually make any changes to the common start + menu. This is most likely only the case if the user + has administrative rights! */ + if (IsUserAnAdmin()) + { + AppendMenu(hPopup, + MF_SEPARATOR, + 0, + NULL); + + /* Add the "Open All Users" menu item */ + if (LoadString(hExplorerInstance, + IDS_OPEN_ALL_USERS, + szBuf, + sizeof(szBuf) / sizeof(szBuf[0]))) + { + AppendMenu(hPopup, + MF_STRING, + ID_SHELL_CMD_OPEN_ALL_USERS, + szBuf); + } + + /* Add the "Explore All Users" menu item */ + if (LoadString(hExplorerInstance, + IDS_EXPLORE_ALL_USERS, + szBuf, + sizeof(szBuf) / sizeof(szBuf[0]))) + { + AppendMenu(hPopup, + MF_STRING, + ID_SHELL_CMD_EXPLORE_ALL_USERS, + szBuf); + } + } + } + } + } + +public: + HRESULT Initialize(ITrayWindow * pTrayWnd, IN HWND hWndOwner) + { + this->TrayWnd = pTrayWnd; + this->hWndOwner = hWndOwner; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE + QueryContextMenu(HMENU hPopup, + UINT indexMenu, + UINT idCmdFirst, + UINT idCmdLast, + UINT uFlags) + { + LPITEMIDLIST pidlStart; + CComPtr<IShellFolder> psfDesktop; + HRESULT hRet; + + psfDesktop = NULL; + pcm = NULL; + + pidlStart = SHCloneSpecialIDList(hWndOwner, CSIDL_STARTMENU, TRUE); + + if (pidlStart != NULL) + { + pidl = ILClone(ILFindLastID(pidlStart)); + ILRemoveLastID(pidlStart); + + if (pidl != NULL) + { + hRet = SHGetDesktopFolder(&psfDesktop); + if (SUCCEEDED(hRet)) + { + hRet = psfDesktop->BindToObject(pidlStart, NULL, IID_PPV_ARG(IShellFolder, &psf)); + if (SUCCEEDED(hRet)) + { + CreateContextMenuFromShellFolderPidl(hPopup); + AddStartContextMenuItems(hPopup); + } + } + } + + ILFree(pidlStart); + } + + return NULL; + } + + virtual HRESULT STDMETHODCALLTYPE + InvokeCommand(LPCMINVOKECOMMANDINFO lpici) + { + UINT uiCmdId = (UINT)lpici->lpVerb; + if (uiCmdId != 0) + { + if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST)) + { + CMINVOKECOMMANDINFO cmici = { 0 }; + CHAR szDir[MAX_PATH]; + + /* Setup and invoke the shell command */ + cmici.cbSize = sizeof(cmici); + cmici.hwnd = hWndOwner; + cmici.lpVerb = MAKEINTRESOURCEA(uiCmdId - ID_SHELL_CMD_FIRST); + cmici.nShow = SW_NORMAL; + + /* FIXME: Support Unicode!!! */ + if (SHGetPathFromIDListA(pidl, szDir)) + { + cmici.lpDirectory = szDir; + } + + pcm->InvokeCommand(&cmici); + } + else + { + TrayWnd->ExecContextMenuCmd(uiCmdId); + } + } + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE + GetCommandString(UINT_PTR idCmd, + UINT uType, + UINT *pwReserved, + LPSTR pszName, + UINT cchMax) + { + return E_NOTIMPL; + } + + CStartMenuBtnCtxMenu() + { + } + + virtual ~CStartMenuBtnCtxMenu() + { + if (pidl) + ILFree(pidl); + } + + BEGIN_COM_MAP(CStartMenuBtnCtxMenu) + COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) + END_COM_MAP() }; - -static HMENU -CreateContextMenuFromShellFolderPidl(IN HWND hWndOwner, - IN OUT IShellFolder *psf, - IN OUT LPITEMIDLIST pidl, - OUT IContextMenu **ppcm) +HRESULT StartMenuBtnCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu) { - CComPtr<IContextMenu> pcm; - HRESULT hRet; - HMENU hPopup; - - hRet = psf->GetUIObjectOf(hWndOwner, 1, (LPCITEMIDLIST *) &pidl, IID_NULL_PPV_ARG(IContextMenu, &pcm)); - if (SUCCEEDED(hRet)) - { - hPopup = CreatePopupMenu(); - - if (hPopup != NULL) - { - hRet = pcm->QueryContextMenu( - hPopup, - 0, - ID_SHELL_CMD_FIRST, - ID_SHELL_CMD_LAST, - CMF_VERBSONLY); - - if (SUCCEEDED(hRet)) - { - *ppcm = pcm; - return hPopup; - } - - DestroyMenu(hPopup); - } - } - - return NULL; + CStartMenuBtnCtxMenu * mnu = new CComObject<CStartMenuBtnCtxMenu>(); + mnu->Initialize(TrayWnd, hWndOwner); + *ppCtxMenu = mnu; + return S_OK; } - -static VOID -OnStartContextMenuCommand(IN HWND hWndOwner, - IN UINT uiCmdId, - IN PVOID pcmContext OPTIONAL, - IN PVOID Context OPTIONAL) -{ - PSTARTMNU_CTMENU_CTX psmcmc = (PSTARTMNU_CTMENU_CTX) pcmContext; - - if (uiCmdId != 0) - { - if ((uiCmdId >= ID_SHELL_CMD_FIRST) && (uiCmdId <= ID_SHELL_CMD_LAST)) - { - CMINVOKECOMMANDINFO cmici = { 0 }; - CHAR szDir[MAX_PATH]; - - /* Setup and invoke the shell command */ - cmici.cbSize = sizeof(cmici); - cmici.hwnd = hWndOwner; - cmici.lpVerb = (LPCSTR) MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST); - cmici.nShow = SW_NORMAL; - - /* FIXME: Support Unicode!!! */ - if (SHGetPathFromIDListA(psmcmc->pidl, - szDir)) - { - cmici.lpDirectory = szDir; - } - - psmcmc->pcm->InvokeCommand(&cmici); - } - else - { - ITrayWindow * TrayWnd = (ITrayWindow *) Context; - TrayWnd->ExecContextMenuCmd(uiCmdId); - } - } - - psmcmc->pcm->Release(); - - HeapFree(hProcessHeap, 0, psmcmc); -} - -static VOID -AddStartContextMenuItems(IN HWND hWndOwner, IN HMENU hPopup) -{ - WCHAR szBuf[MAX_PATH]; - HRESULT hRet; - - /* Add the "Open All Users" menu item */ - if (LoadString(hExplorerInstance, - IDS_PROPERTIES, - szBuf, - sizeof(szBuf) / sizeof(szBuf[0]))) - { - AppendMenu(hPopup, - MF_STRING, - ID_SHELL_CMD_PROPERTIES, - szBuf); - } - - if (!SHRestricted(REST_NOCOMMONGROUPS)) - { - /* Check if we should add menu items for the common start menu */ - hRet = SHGetFolderPath(hWndOwner, - CSIDL_COMMON_STARTMENU, - NULL, - SHGFP_TYPE_CURRENT, - szBuf); - if (SUCCEEDED(hRet) && hRet != S_FALSE) - { - /* The directory exists, but only show the items if the - user can actually make any changes to the common start - menu. This is most likely only the case if the user - has administrative rights! */ - if (IsUserAnAdmin()) - { - AppendMenu(hPopup, - MF_SEPARATOR, - 0, - NULL); - - /* Add the "Open All Users" menu item */ - if (LoadString(hExplorerInstance, - IDS_OPEN_ALL_USERS, - szBuf, - sizeof(szBuf) / sizeof(szBuf[0]))) - { - AppendMenu(hPopup, - MF_STRING, - ID_SHELL_CMD_OPEN_ALL_USERS, - szBuf); - } - - /* Add the "Explore All Users" menu item */ - if (LoadString(hExplorerInstance, - IDS_EXPLORE_ALL_USERS, - szBuf, - sizeof(szBuf) / sizeof(szBuf[0]))) - { - AppendMenu(hPopup, - MF_STRING, - ID_SHELL_CMD_EXPLORE_ALL_USERS, - szBuf); - } - } - } - } -} - -static HMENU -CreateStartContextMenu(IN HWND hWndOwner, - IN PVOID *ppcmContext, - IN PVOID Context OPTIONAL) -{ - LPITEMIDLIST pidlStart, pidlLast; - CComPtr<IShellFolder> psfStart; - CComPtr<IShellFolder> psfDesktop; - CComPtr<IContextMenu> pcm; - HRESULT hRet; - HMENU hPopup; - - pidlStart = SHCloneSpecialIDList(hWndOwner, - CSIDL_STARTMENU, - TRUE); - - if (pidlStart != NULL) - { - pidlLast = ILClone(ILFindLastID(pidlStart)); - ILRemoveLastID(pidlStart); - - if (pidlLast != NULL) - { - hRet = SHGetDesktopFolder(&psfDesktop); - if (SUCCEEDED(hRet)) - { - hRet = psfDesktop->BindToObject(pidlStart, NULL, IID_PPV_ARG(IShellFolder, &psfStart)); - if (SUCCEEDED(hRet)) - { - hPopup = CreateContextMenuFromShellFolderPidl(hWndOwner, - psfStart, - pidlLast, - &pcm); - - if (hPopup != NULL) - { - PSTARTMNU_CTMENU_CTX psmcmc; - - psmcmc = (PSTARTMNU_CTMENU_CTX) HeapAlloc(hProcessHeap, 0, sizeof(*psmcmc)); - if (psmcmc != NULL) - { - psmcmc->pcm = pcm; - psmcmc->pidl = pidlLast; - - AddStartContextMenuItems(hWndOwner, - hPopup); - - *ppcmContext = psmcmc; - return hPopup; - } - else - { - DestroyMenu(hPopup); - hPopup = NULL; - } - } - } - } - - ILFree(pidlLast); - } - - ILFree(pidlStart); - } - - return NULL; -} Modified: branches/shell-experiments/base/shell/explorer-new/traywnd.cpp URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
============================================================================== --- branches/shell-experiments/base/shell/explorer-new/traywnd.cpp [iso-8859-1] (original) +++ branches/shell-experiments/base/shell/explorer-new/traywnd.cpp [iso-8859-1] Thu Nov 6 03:05:33 2014 @@ -24,7 +24,7 @@ extern HRESULT InitShellServices(HDPA * phdpa); extern HRESULT ShutdownShellServices(HDPA hdpa); -extern const TRAYWINDOW_CTXMENU TrayWindowCtxMenu; +HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu); #define WM_APP_TRAYDESTROY (WM_APP + 0x100) @@ -70,7 +70,6 @@ HFONT hStartBtnFont; HFONT hCaptionFont; - CComPtr<ITrayBandSite> TrayBandSite; HWND hwndRebar; HWND hwndTaskSwitch; HWND hwndTrayNotify; @@ -84,6 +83,25 @@ RECT rcTrayWnd[4]; RECT rcNewPosSize; SIZE TraySize; + + NONCLIENTMETRICS ncm; + HFONT hFont; + + CComPtr<IMenuBand> StartMenuBand; + CComPtr<IMenuPopup> StartMenuPopup; + HBITMAP hbmStartMenu; + + HWND hwndTrayPropertiesOwner; + HWND hwndRunFileDlgOwner; + + UINT AutoHideState; + SIZE AutoHideOffset; + TRACKMOUSEEVENT MouseTrackingInfo; + + HDPA hdpaShellServices; + +public: + CComPtr<ITrayBandSite> TrayBandSite; union { DWORD Flags; @@ -101,22 +119,6 @@ DWORD NewPosSize : 1; }; }; - - NONCLIENTMETRICS ncm; - HFONT hFont; - - CComPtr<IMenuBand> StartMenuBand; - CComPtr<IMenuPopup> StartMenuPopup; - HBITMAP hbmStartMenu; - - HWND hwndTrayPropertiesOwner; - HWND hwndRunFileDlgOwner; - - UINT AutoHideState; - SIZE AutoHideOffset; - TRACKMOUSEEVENT MouseTrackingInfo; - - HDPA hdpaShellServices; public: CTrayWindow() : @@ -134,13 +136,13 @@ PreviousMonitor(NULL), DraggingPosition(0), DraggingMonitor(NULL), - Flags(0), hFont(NULL), hbmStartMenu(NULL), hwndTrayPropertiesOwner(NULL), hwndRunFileDlgOwner(NULL), AutoHideState(NULL), - hdpaShellServices(NULL) + hdpaShellServices(NULL), + Flags(0) { ZeroMemory(&StartBtnSize, sizeof(StartBtnSize)); ZeroMemory(&rcTrayWnd, sizeof(rcTrayWnd)); @@ -1017,38 +1019,51 @@ return cmdId; } - UINT TrackCtxMenu( - IN const TRAYWINDOW_CTXMENU *pMenu, + HRESULT TrackCtxMenu( + IN IContextMenu * contextMenu, IN POINT *ppt OPTIONAL, IN HWND hwndExclude OPTIONAL, IN BOOL TrackUp, IN PVOID Context OPTIONAL) { - HMENU hPopup; - UINT cmdId = 0; - PVOID pcmContext = NULL; - - hPopup = pMenu->CreateCtxMenu(m_hWnd, - &pcmContext, - Context); - if (hPopup != NULL) - { - cmdId = TrackMenu( - hPopup, - ppt, - hwndExclude, - TrackUp, - TRUE); - - pMenu->CtxMenuCommand(m_hWnd, - cmdId, - pcmContext, - Context); - - DestroyMenu(hPopup); - } - - return cmdId; + INT x = ppt->x; + INT y = ppt->y; + HRESULT hr; + UINT uCommand; + HMENU popup = CreatePopupMenu(); + + if (popup == NULL) + return E_FAIL; + + TRACE("Before Query\n"); + hr = contextMenu->QueryContextMenu(popup, 0, 0, UINT_MAX, CMF_NORMAL); + if (FAILED_UNEXPECTEDLY(hr)) + { + TRACE("Query failed\n"); + DestroyMenu(popup); + return hr; + } + + TRACE("Before Tracking\n"); + uCommand = ::TrackPopupMenuEx(popup, TPM_RETURNCMD, x, y, m_hWnd, NULL); + + if (uCommand != 0) + { + TRACE("Before InvokeCommand\n"); + CMINVOKECOMMANDINFO cmi = { 0 }; + cmi.cbSize = sizeof(cmi); + cmi.lpVerb = MAKEINTRESOURCEA(uCommand); + cmi.hwnd = m_hWnd; + hr = contextMenu->InvokeCommand(&cmi); + } + else + { + TRACE("TrackPopupMenu failed. Code=%d, LastError=%d\n", uCommand, GetLastError()); + hr = S_FALSE; + } + + DestroyMenu(popup); + return hr; } @@ -2480,12 +2495,9 @@ menu is currently being shown */ if (!(StartButton.SendMessage(BM_GETSTATE, 0, 0) & BST_PUSHED)) { - TrackCtxMenu( - &StartMenuBtnCtxMenu, - ppt, - hWndExclude, - Position == ABE_BOTTOM, - this); + CComPtr<IContextMenu> ctxMenu; + StartMenuBtnCtxMenuCreator(this, m_hWnd, &ctxMenu); + TrackCtxMenu(ctxMenu, ppt, hWndExclude, Position == ABE_BOTTOM, this); } } else @@ -2522,12 +2534,9 @@ { HandleTrayContextMenu: /* Tray the default tray window context menu */ - TrackCtxMenu( - &TrayWindowCtxMenu, - ppt, - NULL, - FALSE, - this); + CComPtr<IContextMenu> ctxMenu; + TrayWindowCtxMenuCreator(this, m_hWnd, &ctxMenu); + TrackCtxMenu(ctxMenu, ppt, NULL, FALSE, this); } } return Ret; @@ -2816,89 +2825,6 @@ ALT_MSG_MAP(1) END_MSG_MAP() - /* - * Tray Window Context Menu - */ - - static HMENU CreateTrayWindowContextMenu(IN HWND hWndOwner, - IN PVOID *ppcmContext, - IN PVOID Context OPTIONAL) - { - CTrayWindow *This = (CTrayWindow *) Context; - IContextMenu *pcm = NULL; - HMENU hPopup; - - hPopup = LoadPopupMenu(hExplorerInstance, - MAKEINTRESOURCE(IDM_TRAYWND)); - - if (hPopup != NULL) - { - if (SHRestricted(REST_CLASSICSHELL) != 0) - { - DeleteMenu(hPopup, - ID_LOCKTASKBAR, - MF_BYCOMMAND); - } - - CheckMenuItem(hPopup, - ID_LOCKTASKBAR, - MF_BYCOMMAND | (This->Locked ? MF_CHECKED : MF_UNCHECKED)); - - if (This->TrayBandSite != NULL) - { - if (SUCCEEDED(This->TrayBandSite->AddContextMenus( - hPopup, - 0, - ID_SHELL_CMD_FIRST, - ID_SHELL_CMD_LAST, - CMF_NORMAL, - &pcm))) - { - TRACE("ITrayBandSite::AddContextMenus succeeded!\n"); - *(IContextMenu **) ppcmContext = pcm; - } - } - } - - return hPopup; - } - - static VOID OnTrayWindowContextMenuCommand(IN HWND hWndOwner, - IN UINT uiCmdId, - IN PVOID pcmContext OPTIONAL, - IN PVOID Context OPTIONAL) - { - CTrayWindow *This = (CTrayWindow *) Context; - IContextMenu *pcm = (IContextMenu *) pcmContext; - - if (uiCmdId != 0) - { - if (uiCmdId >= ID_SHELL_CMD_FIRST && uiCmdId <= ID_SHELL_CMD_LAST) - { - CMINVOKECOMMANDINFO cmici = { 0 }; - - if (pcm != NULL) - { - /* Setup and invoke the shell command */ - cmici.cbSize = sizeof(cmici); - cmici.hwnd = hWndOwner; - cmici.lpVerb = (LPCSTR) MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST); - cmici.nShow = SW_NORMAL; - - pcm->InvokeCommand( - &cmici); - } - } - else - { - This->ExecContextMenuCmd(uiCmdId); - } - } - - if (pcm != NULL) - pcm->Release(); - } - /*****************************************************************************/ VOID TrayProcessMessages() @@ -3017,10 +2943,147 @@ END_COM_MAP() }; -const TRAYWINDOW_CTXMENU TrayWindowCtxMenu = { - CTrayWindow::CreateTrayWindowContextMenu, - CTrayWindow::OnTrayWindowContextMenuCommand +class CTrayWindowCtxMenu : + public CComCoClass<CTrayWindowCtxMenu>, + public CComObjectRootEx<CComMultiThreadModelNoCS>, + public IContextMenu +{ + HWND hWndOwner; + CComPtr<CTrayWindow> TrayWnd; + CComPtr<IContextMenu> pcm; + +public: + HRESULT Initialize(ITrayWindow * pTrayWnd, IN HWND hWndOwner) + { + this->TrayWnd = (CTrayWindow *) pTrayWnd; + this->hWndOwner = hWndOwner; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE + QueryContextMenu(HMENU hPopup, + UINT indexMenu, + UINT idCmdFirst, + UINT idCmdLast, + UINT uFlags) + { + HMENU menubase = LoadPopupMenu(hExplorerInstance, MAKEINTRESOURCE(IDM_TRAYWND)); + + if (menubase) + { + int count = ::GetMenuItemCount(menubase); + + for (int i = 0; i < count; i++) + { + WCHAR label[128]; + + MENUITEMINFOW mii = { 0 }; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS + | MIIM_DATA | MIIM_STRING | MIIM_BITMAP | MIIM_FTYPE; + mii.dwTypeData = label; + mii.cch = _countof(label); + ::GetMenuItemInfoW(menubase, i, TRUE, &mii); + + TRACE("Adding item %d label %S type %d\n", mii.wID, mii.dwTypeData, mii.fType); + + mii.fType |= MFT_RADIOCHECK; + + ::InsertMenuItemW(hPopup, i + 1, TRUE, &mii); + } + + ::DestroyMenu(menubase); + + if (SHRestricted(REST_CLASSICSHELL) != 0) + { + DeleteMenu(hPopup, + ID_LOCKTASKBAR, + MF_BYCOMMAND); + } + + CheckMenuItem(hPopup, + ID_LOCKTASKBAR, + MF_BYCOMMAND | (TrayWnd->Locked ? MF_CHECKED : MF_UNCHECKED)); + + if (TrayWnd->TrayBandSite != NULL) + { + if (SUCCEEDED(TrayWnd->TrayBandSite->AddContextMenus( + hPopup, + 0, + ID_SHELL_CMD_FIRST, + ID_SHELL_CMD_LAST, + CMF_NORMAL, + &pcm))) + { + return S_OK; + } + } + + } + + return E_FAIL; + } + + virtual HRESULT STDMETHODCALLTYPE + InvokeCommand(LPCMINVOKECOMMANDINFO lpici) + { + UINT uiCmdId = (UINT) lpici->lpVerb; + if (uiCmdId != 0) + { + if (uiCmdId >= ID_SHELL_CMD_FIRST && uiCmdId <= ID_SHELL_CMD_LAST) + { + CMINVOKECOMMANDINFO cmici = { 0 }; + + if (pcm != NULL) + { + /* Setup and invoke the shell command */ + cmici.cbSize = sizeof(cmici); + cmici.hwnd = hWndOwner; + cmici.lpVerb = (LPCSTR) MAKEINTRESOURCE(uiCmdId - ID_SHELL_CMD_FIRST); + cmici.nShow = SW_NORMAL; + + pcm->InvokeCommand(&cmici); + } + } + else + { + TrayWnd->ExecContextMenuCmd(uiCmdId); + } + } + + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE + GetCommandString(UINT_PTR idCmd, + UINT uType, + UINT *pwReserved, + LPSTR pszName, + UINT cchMax) + { + return E_NOTIMPL; + } + + CTrayWindowCtxMenu() + { + } + + virtual ~CTrayWindowCtxMenu() + { + } + + BEGIN_COM_MAP(CTrayWindowCtxMenu) + COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) + END_COM_MAP() }; + +HRESULT TrayWindowCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu) +{ + CTrayWindowCtxMenu * mnu = new CComObject<CTrayWindowCtxMenu>(); + mnu->Initialize(TrayWnd, hWndOwner); + *ppCtxMenu = mnu; + return S_OK; +} CTrayWindow * g_TrayWindow;
10 years
1
0
0
0
[tfaber] 65278: [FASTFAT] - Fix failure case handling in vfatUpdateFCB - NULL output parameters on failure in vfatGetFCBForFile - Fix a few typos
by tfaber@svn.reactos.org
Author: tfaber Date: Thu Nov 6 00:07:01 2014 New Revision: 65278 URL:
http://svn.reactos.org/svn/reactos?rev=65278&view=rev
Log: [FASTFAT] - Fix failure case handling in vfatUpdateFCB - NULL output parameters on failure in vfatGetFCBForFile - Fix a few typos Modified: trunk/reactos/drivers/filesystems/fastfat/create.c trunk/reactos/drivers/filesystems/fastfat/fcb.c Modified: trunk/reactos/drivers/filesystems/fastfat/create.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Thu Nov 6 00:07:01 2014 @@ -583,7 +583,7 @@ idx = FileObject->FileName.Length / sizeof(WCHAR) - 1; - /* Skip tailing \ - if any */ + /* Skip trailing \ - if any */ if (PathNameU.Buffer[idx] == L'\\') { --idx; Modified: trunk/reactos/drivers/filesystems/fastfat/fcb.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat/fcb.c [iso-8859-1] Thu Nov 6 00:07:01 2014 @@ -371,21 +371,21 @@ DPRINT("vfatUpdateFCB(%p, %p, %wZ, %wZ, %p)\n", pVCB, Fcb, LongName, ShortName, ParentFcb); - /* Delete old name */ - if (Fcb->PathNameBuffer) - { - ExFreePoolWithTag(Fcb->PathNameBuffer, TAG_FCB); - } - - /* Delete from table */ - vfatDelFCBFromTable(pVCB, Fcb); - /* Get full path name */ Status = vfatMakeFullName(ParentFcb, LongName, ShortName, &Fcb->PathNameU); if (!NT_SUCCESS(Status)) { return Status; } + + /* Delete old name */ + if (Fcb->PathNameBuffer) + { + ExFreePoolWithTag(Fcb->PathNameBuffer, TAG_FCB); + } + + /* Delete from table */ + vfatDelFCBFromTable(pVCB, Fcb); /* Split it properly */ Fcb->PathNameBuffer = Fcb->PathNameU.Buffer; @@ -414,8 +414,8 @@ /* Add to the table */ vfatAddFCBToTable(pVCB, Fcb); - /* If we moved accross directories, dereferenced our old parent - * We also derefence in case we're just renaming since AddFCBToTable references it + /* If we moved across directories, dereference our old parent + * We also dereference in case we're just renaming since AddFCBToTable references it */ vfatReleaseFCB(pVCB, OldParent); @@ -887,7 +887,7 @@ if (parentFCB) { vfatReleaseFCB(pVCB, parentFCB); - parentFCB = 0; + parentFCB = NULL; } // fail if element in FCB is not a directory if (!vfatFCBIsDirectory(FCB)) @@ -910,6 +910,8 @@ if (FileNameU.Length + parentFCB->LongNameU.Length - Length > FileNameU.MaximumLength) { vfatReleaseFCB(pVCB, parentFCB); + *pParentFCB = NULL; + *pFCB = NULL; return STATUS_OBJECT_NAME_INVALID; } RtlMoveMemory(prev + parentFCB->LongNameU.Length / sizeof(WCHAR), curr,
10 years
1
0
0
0
[tfaber] 65277: [NTOS:IO] - Silence super noisy debug print in IopQueryAttributesFile
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Nov 5 23:27:04 2014 New Revision: 65277 URL:
http://svn.reactos.org/svn/reactos?rev=65277&view=rev
Log: [NTOS:IO] - Silence super noisy debug print in IopQueryAttributesFile Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c Modified: trunk/reactos/ntoskrnl/io/iomgr/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/file.c?r…
============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/file.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/file.c [iso-8859-1] Wed Nov 5 23:27:04 2014 @@ -1580,8 +1580,8 @@ if (OpenPacket.ParseCheck != TRUE) { /* Parse failed */ - DPRINT1("IopQueryAttributesFile failed for '%wZ' with 0x%lx\n", - ObjectAttributes->ObjectName, Status); + DPRINT("IopQueryAttributesFile failed for '%wZ' with 0x%lx\n", + ObjectAttributes->ObjectName, Status); return Status; } else
10 years
1
0
0
0
[tfaber] 65276: [FASTFAT] - Fix incorrect referencing in VfatCreateFile. vfatGetFCBForFile expects a reference on ParentFcb (and may release it), and also returns a referenced parent FCB. CORE-8756...
by tfaber@svn.reactos.org
Author: tfaber Date: Wed Nov 5 23:23:52 2014 New Revision: 65276 URL:
http://svn.reactos.org/svn/reactos?rev=65276&view=rev
Log: [FASTFAT] - Fix incorrect referencing in VfatCreateFile. vfatGetFCBForFile expects a reference on ParentFcb (and may release it), and also returns a referenced parent FCB. CORE-8756 #resolve Modified: trunk/reactos/drivers/filesystems/fastfat/create.c trunk/reactos/drivers/filesystems/fastfat/direntry.c trunk/reactos/drivers/filesystems/fastfat/dirwr.c Modified: trunk/reactos/drivers/filesystems/fastfat/create.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat/create.c [iso-8859-1] Wed Nov 5 23:23:52 2014 @@ -565,11 +565,14 @@ LONG idx, FileNameLen; ParentFcb = (FileObject->RelatedFileObject != NULL) ? FileObject->RelatedFileObject->FsContext : NULL; + if (ParentFcb) + { + vfatGrabFCB(DeviceExt, ParentFcb); + } Status = vfatGetFCBForFile(DeviceExt, &ParentFcb, &TargetFcb, &PathNameU); - if (Status == STATUS_SUCCESS) - { - vfatGrabFCB(DeviceExt, ParentFcb); + if (NT_SUCCESS(Status)) + { vfatReleaseFCB(DeviceExt, TargetFcb); Irp->IoStatus.Information = FILE_EXISTS; } @@ -623,6 +626,7 @@ if (NT_SUCCESS(Status)) { pFcb = FileObject->FsContext; + ASSERT(pFcb == ParentFcb); if (pFcb->OpenHandleCount == 0) { @@ -640,7 +644,6 @@ FALSE); if (!NT_SUCCESS(Status)) { - vfatReleaseFCB(DeviceExt, ParentFcb); VfatCloseFile(DeviceExt, FileObject); return Status; } Modified: trunk/reactos/drivers/filesystems/fastfat/direntry.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat/direntry.c [iso-8859-1] Wed Nov 5 23:23:52 2014 @@ -201,12 +201,6 @@ CcUnpinData(*pContext); } - if (!pDirFcb->FileObject) - { - DPRINT1("Buggy FCB (cleaned up)! %S (%d / %u)\n", pDirFcb->PathNameBuffer, pDirFcb->RefCount, pDirFcb->OpenHandleCount); - return STATUS_NO_MORE_ENTRIES; - } - if (FileOffset.u.LowPart >= pDirFcb->RFCB.FileSize.u.LowPart || !CcMapData(pDirFcb->FileObject, &FileOffset, PAGE_SIZE, TRUE, pContext, pPage)) { Modified: trunk/reactos/drivers/filesystems/fastfat/dirwr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
============================================================================== --- trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat/dirwr.c [iso-8859-1] Wed Nov 5 23:23:52 2014 @@ -166,11 +166,6 @@ if (Context) { CcUnpinData(Context); - } - if (!pDirFcb->FileObject) - { - DPRINT1("Buggy FCB (cleaned up)! %S (%d / %u)\n", pDirFcb->PathNameBuffer, pDirFcb->RefCount, pDirFcb->OpenHandleCount); - return FALSE; } if (!CcPinRead(pDirFcb->FileObject, &FileOffset, DeviceExt->FatInfo.BytesPerCluster, TRUE, &Context, (PVOID*)&pFatEntry))
10 years
1
0
0
0
← Newer
1
...
23
24
25
26
27
28
29
...
38
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Results per page:
10
25
50
100
200