sharpshell icon indicating copy to clipboard operation
sharpshell copied to clipboard

Getting current IShellView from SharpDropHandler

Open windowsdeveloperwannabe opened this issue 6 years ago • 8 comments

Hello, I am changing filenames with SharpDropHandler. But Explorer does not sort the files until I refresh with F5, so it is hard for the user to notice the change.

Is there any way to get a handle of the current IShellView in SharpDropHandler::Drop? I would like to call this method IShellView::Refresh to refresh the view and maybe even IShellView::SelectItem to select the changed files.

Sorry if weird or impossible question. 😅

windowsdeveloperwannabe avatar Jan 27 '19 10:01 windowsdeveloperwannabe

Looks like you need to copy-paste reimplement SharpDropHandler with some additional interfaces.

I also had to fork the entire project because SharpShell.Attributes.ServerTypeAttribute class needed by the handler is marked internal so I had to change it to be public. 😩 The project is very easy to develop and build though so can't complain. 👍

windowsdeveloperwannabe avatar Jan 30 '19 13:01 windowsdeveloperwannabe

@windowsdeveloperwannabe mind if I re-open? I'd like to fix this in the mainline! Or if you can share a PR that'd be great :) PS glad you found the project easy to build, I've tried to make it as straightforward as possible to allow people to get it running locally!

dwmkerr avatar Jan 30 '19 13:01 dwmkerr

@windowsdeveloperwannabe hi, did you implement the refresh function? if yes? could you please share your approch.

taiyangluoshan88 avatar Feb 06 '19 01:02 taiyangluoshan88

hello, is this issue fixed or have any other workaround?

taiyangluoshan88 avatar Feb 22 '19 14:02 taiyangluoshan88

@taiyangluoshan88 Hello, I'm afraid IShellView::Refresh is a way too expensive of an operation for your problem. When I got it working it took a subsecond to refresh the Explorer view. Somehow Refresh is totally different from a simple F5 in your explorer, so I couldn't use it for my problem either.

I'm currently trying out more shell extension interfaces in regular C++ (just got finished with the boilerplate :sweat_smile:). If do find something to solve your problem I'll send a message. :slightly_smiling_face:

windowsdeveloperwannabe avatar Mar 03 '19 09:03 windowsdeveloperwannabe

got it, thanks for your replay and hopeful you can find the approach to solve this issue.

taiyangluoshan88 avatar Mar 03 '19 10:03 taiyangluoshan88

I can look at this, but it might be a week or so, I'd be happy for any proposed PRs to expose the interface though!

dwmkerr avatar Mar 04 '19 03:03 dwmkerr

Got some time to continue looking into this. Actually IShellView::Refresh is not at all expensive at least when called from a regular C++ shell extension. Not sure what it means, maybe I had really bad COM marshaling in C# or something. :thinking:

It does change scroll position though, so in that sense it's somewhat annoying. Maybe there's still some other way to reload icons.

windowsdeveloperwannabe avatar Apr 04 '19 14:04 windowsdeveloperwannabe