From a09e9033983611a9485d006948a3edf836927a7b Mon Sep 17 00:00:00 2001 From: Stanislav Motylkov Date: Tue, 8 Nov 2022 17:52:04 +0300 Subject: [PATCH] [SHELL32] CDrivesFolder: Unhardcode pqcminfo->idCmdFirst value DFM_MERGECONTEXTMENU handler works better now. However there is difference between ours and Windows' menu building systems, which has to be fixed. Addendum to 64657051c3c. CORE-13841 CORE-18577 --- dll/win32/shell32/folders/CDrivesFolder.cpp | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp b/dll/win32/shell32/folders/CDrivesFolder.cpp index 805bfee1ac0..bf0dde7c9d6 100644 --- a/dll/win32/shell32/folders/CDrivesFolder.cpp +++ b/dll/win32/shell32/folders/CDrivesFolder.cpp @@ -286,38 +286,52 @@ HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder *psf, GetVolumeInformationA(szDrive, NULL, 0, NULL, NULL, &dwFlags, NULL, 0); // custom command IDs +#if 0 // Disabled until our menu building system is fixed +#define CMDID_FORMAT 0 +#define CMDID_EJECT 1 +#define CMDID_DISCONNECT 2 +#else +/* FIXME: These IDs should start from 0, however there is difference + * between ours and Windows' menu building systems, which should be fixed. */ #define CMDID_FORMAT 1 #define CMDID_EJECT 2 #define CMDID_DISCONNECT 3 +#endif if (uMsg == DFM_MERGECONTEXTMENU) { QCMINFO *pqcminfo = (QCMINFO *)lParam; UINT idCmdFirst = pqcminfo->idCmdFirst; + UINT idCmd = 0; if (!(dwFlags & FILE_READ_ONLY_VOLUME) && nDriveType != DRIVE_REMOTE) { /* add separator and Format */ - UINT idCmd = idCmdFirst + CMDID_FORMAT; + idCmd = idCmdFirst + CMDID_FORMAT; _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, idCmd, MFT_STRING, MAKEINTRESOURCEW(IDS_FORMATDRIVE), MFS_ENABLED); } if (nDriveType == DRIVE_REMOVABLE || nDriveType == DRIVE_CDROM) { /* add separator and Eject */ - UINT idCmd = idCmdFirst + CMDID_EJECT; + idCmd = idCmdFirst + CMDID_EJECT; _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, idCmd, MFT_STRING, MAKEINTRESOURCEW(IDS_EJECT), MFS_ENABLED); } if (nDriveType == DRIVE_REMOTE) { /* add separator and Disconnect */ - UINT idCmd = idCmdFirst + CMDID_DISCONNECT; + idCmd = idCmdFirst + CMDID_DISCONNECT; _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, 0, MFT_SEPARATOR, NULL, 0); _InsertMenuItemW(pqcminfo->hmenu, pqcminfo->indexMenu++, TRUE, idCmd, MFT_STRING, MAKEINTRESOURCEW(IDS_DISCONNECT), MFS_ENABLED); } - pqcminfo->idCmdFirst += 3; + if (idCmd) +#if 0 // see FIXME above + pqcminfo->idCmdFirst = ++idCmd; +#else + pqcminfo->idCmdFirst = (idCmd + 2); +#endif } else if (uMsg == DFM_INVOKECOMMAND) {