-----Original Message-----
Hmmm, not really... it seems to work pretty well for me.
Maybe you should post some code so we can see what you're
doing. Where is your handler registered?
Jim,
Are you saying that you're using IShellView::SelectItem
and it's actually working? As I said before, I am and it's
not working. I call SelectItem and pass it a folder
relative pidl and I get no error but the item is not
selected.
I could post the code since it's just a utility I wrote
for my own use, but it's pretty big and I'd need to pare
it down before I could post it. Please, do me a favor and
give me a sanity check with what I'm currently doing.
1. My context menu's Initialize function gets called.
The function uses the passed-in IdataObject to build a
vector of strings containing the full paths of the
selected items. The function also extracts the folder's
path using the path of the first selected item. The vector
of file paths and the folder path are saved as data
members in the class.
2. The user selects a menu command. In this
case "Rename All".
3. My menu's InvokeCommand function gets called.
InvokeCommand calls SHGetDesktopFolder and uses that
interface's ParseDisplayName to get the full pidl of the
folder saved in step 1. The folder pidl is then passed to
the desktop's IShellFolder::BindToObject function which
returns the IShellFolder for the folder. This
IShellFolder's CreateViewObject function is called to get
the IShellView for the folder. InvokeCommand then calls
the RenameAll member function of the context menu class.
4. The RenameAll function pops up a dialog which
allows the user to enter a base filename and set an option
to append either a sequential number or a random number to
the base filename for each item to be renamed. When the
user OKs the dialog the function calls the RenameItem
function for each item in the vector, passing it the
current and new filenames with the paths stripped off
(filenames without path.)
5. The RenameItem function uses the IShellFolder's
ParseDisplayName to get the relative pidl for the item to
be renamed. It then calls the IShellView's SetNameOf
function to rename the item with the new filename.
SetNameOf returns the new pidl for the renamed item. Then
the IShellView's SelectItem function is called with the
new pidl of the item.
All of this works. The item is renamed correctly and
SelectItem reports no errors, but as soon as the context
menu is finished the selection states are lost. Well, most
of them are lost anyway. If I have a bunch of files
selected, say 20-30, then ten files always remain selected
and the others become unselected.
Thanks for the help you've given me already. Any new
suggestions will be much appreciated.
Regards,
Mick