shell extension

  • Thread starter Thread starter Rajko
  • Start date Start date
R

Rajko

I used function:

BOOL InsertMenuItem( HMENU hMenu,
UINT uItem,
BOOL fByPosition,
LPCMENUITEMINFO lpmii
);

to add consecutive menu elements in QueryContextMenu() shell interface.
After adding all of them only first one i displyed. I added MF_STRING type
menues.

I checked through debugger, they all are present there in menu.
If i try adding consecutive popup menues it works fine and can add as many
as I want.
Only MF_STRING type menus wont work. Only first inserted menu item is
shown. :-(

Thanks for help, Rajko.
 
I found out what was wrong.
Interface function GetCommandString(..) needed different values for each
inserted menu item.
I case all items have the same help string only first item is displayed.
 
to add consecutive menu elements in QueryContextMenu() shell interface.
After adding all of them only first one i displyed.

Have you returned the correct value - indicating that you've added
multiple menu items?

Dave
 
Thx David.
I included HRESULT(SEVERITY_SUCCESS, 0, idCmd - uidCmdFirst);
With idCmd incremented on each menuInsertItem().
 
I included HRESULT(SEVERITY_SUCCESS, 0, idCmd - uidCmdFirst);
With idCmd incremented on each menuInsertItem().

That sounds like you're doing the right thing there then.

Can you show a short example that illustrates what you have - perhaps
someone can spot something.

Dave
 
Thx for all. Now it's working ok.
Solution was to add different CommandString for each menu item I inserted.

If anyone else have such problem here is what I did.
I have two menues(1st plain menu item and 2nd popup menu).
1st have index m_InsertedCmdIndex and 2nd = InsertedCMCmdIndex.


HRESULT CShellExtension::GetCommandString(UINT idCmd, UINT uFlags, UINT*
pwReserved, LPSTR pszName, UINT cchMax ) {
#ifdef DEBUG_ALL
// MessageBox(NULL,_T("GetCommandString"),_T(""),MB_OK);
#endif
USES_CONVERSION; // create space for temp variables needed for ATL
T2.. macro

if (uFlags & GCS_HELPTEXT) {
CString helpString;
helpString.Format(_T("GCS => idCmd=%d"), idCmd);
if (idCmd == m_InsertedCmdIndex) helpString =
CM_ITEM_DESCRIPTION;
if (idCmd == m_InsertedCMCmdIndex) helpString =
QUICK_CM_ITEM_DESCRIPTION;
if (idCmd > m_InsertedCmdIndex && idCmd < m_InsertedCMCmdIndex)
{
UINT posCM = idCmd - m_InsertedCmdIndex - 1;
CMRenameRegistry CMReg;
CMItem cmItem;
CMReg.GetCM(posCM, &cmItem);
helpString.Format(QUICK_CM_ITEM_NAME, cmItem.Name);
helpString.AppendFormat(QUICK_CM_ITEM_ACTION_NAME,
cmItem.Action1Select, cmItem.Action1Rename);
helpString.AppendFormat(QUICK_CM_ITEM_ACTION_NAME,
cmItem.Action2Select, cmItem.Action2Rename);
helpString.AppendFormat(QUICK_CM_ITEM_ACTION_NAME,
cmItem.Action3Select, cmItem.Action3Rename);
}
// MessageBox(NULL, _T("GCS"), _T(""), MB_OK);
StringCchCopyN((TCHAR *)pszName, cchMax, helpString,
helpString.GetLength());
if (uFlags & GCS_UNICODE) {
} else {
}
}

#ifdef DEBUG_ALL
// MessageBox(NULL,_T("GetCommandString END"),_T(""),MB_OK);
#endif
return NOERROR;
}
 
Back
Top