Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Sun, 9 Mar 2008 12:51:01 -0700,    group: microsoft.public.platformsdk.shell        back       


Shell notifications do not work correctly in custom NSE   
Hi

I've encountered an issue with my NSE. When I create or delete or rename 
folders in my NSE it often ignores shell notifications about the action 
performed so the folder tree or the list folder view do not react to the 
changes. The behaviour is unpredictable. Sometimes it works fine when I make 
changes in NSE's root folder and doesn't work correctly when I make changes 
inside any child folder or vice versa. Actually this it works fine in Vista 
and bad in XP. MSDN contains a few of information about NSEs development so I 
admit that I could made some mistakes in my code. Let me show you some parts 
of it that are responsible for the interacting with shell on my mind.

HRESULT STDMETHODCALLTYPE SV_ShellFolder::CreateViewObject( 
    /* [in] */ HWND hwnd,
    /* [in] */ REFIID riid,
    /* [iid_is][out] */ void **ppv)
{
    .....

        if(riid == __uuidof(IShellView))
        {
            SFV_CREATE sfv;
            sfv.cbSize = sizeof(sfv);
            sfv.psvOuter = NULL;

            // first of all I'm not sure about QueryInterface. Probably 
sfv.pshf = this is enough...
            // MSDN does not tell anything about it.
            tools::hr_verif(QueryInterface(&sfv.pshf));

            // I read that callback handler should be implemented in 
separate object but
            // I'd tried and that was useless so I decided to implement 
IShellFolderViewCB
            // in one class with my shell folder. I hope I's right.
            tools::hr_verif(QueryInterface(&sfv.psfvcb));

            IShellViewPtr view;
            tools::hr_verif(SHCreateShellFolderView(&sfv, &view));

            this->shell_view = view;
            *ppv = view.Detach();

            return S_OK;
 }

    .....
}

HRESULT STDMETHODCALLTYPE SV_ShellFolder::MessageSFVCB(UINT uMsg,
                                                       WPARAM wParam,
                                                       LPARAM lParam)
{
    COM_TRY
    {
        switch(uMsg)
        {
        case SFVM_GETNOTIFY:
            _DBS("SFVM_GETNOTIFY");
            *reinterpret_cast<LPITEMIDLIST*>(wParam) = its_pidl.ptr();
            *reinterpret_cast<PLONG>(lParam) = SHCNE_ALLEVENTS;
            return S_OK;

        case SFVM_FSNOTIFY:
            _DBS("SFVM_FSNOTIFY: 0x" <<std::hex <<lParam);
            return E_NOTIMPL;

        //// Also I'm not sure I need implement SFVM_QUERYFSNOTIFY handler 
because MSDN claims that
        //// this notification is supported on WinXP SP 2 and higher. 
Nevertheless in WinXP SP 1 
        //// I'd received it !!!
        //case SFVM_QUERYFSNOTIFY:
        //    {
        //        _DBS("SFVM_QUERYFSNOTIFY");
        //        SHChangeNotifyEntry* lp = (SHChangeNotifyEntry*)lParam;
        //        lp->pidl = its_pidl.clone().release();
        //        lp->fRecursive = TRUE;
        //    }
        //    return S_OK;

        }
    }
    COM_CATCH_VOID;

    return E_NOTIMPL;
}


After the folder is created I notify the shell about it:

            SHChangeNotify(type == SVO_Storage ? SHCNE_MKDIR : SHCNE_CREATE, 
                SHCNF_IDLIST | SHCNF_FLUSH, pidl1.clone().ptr(), NULL);

But SFVM_FSNOTIFY arrives only if I create a folder inside the root folder 
of my NSE. In any other subfolder I don't receive SFVM_FSNOTIFY. I can't work 
out what is the reason? Anyway the folder tree and the folder view in 
Explorer often do not react on that notification. The same issue is with 
deleting and renaming folders.

I'm sure all the pidl's in the code above are correct and any exception does 
not occur.

I'll be very thankful for any kind of help. Actually I didn't find ANY 
example in the Internet where folder creation, deletion and renaming were 
implemented and I'll be glad if somebody shows me one. Also if it is 
necessary to show any other part of code I'll show it, just tell me.

Thanks a lot.
date: Sun, 9 Mar 2008 12:51:01 -0700   author:   Alexander

Re:Shell notifications do not work correctly in custom NSE   
Why you must use notification? you can manipulate you internal data to 
modify ITEMIDLIST and then refresh to reflect the change on UI.

By the way, What interfaces have you implemented for IShellFolder?

url:http://www.ureader.com/msg/16601103.aspx
date: Mon, 10 Mar 2008 16:50:15 +0800   author:   sunshine

Re:Shell notifications do not work correctly in custom NSE   
Thank you for your response.

> Why you must use notification? you can manipulate you internal data to 
> modify ITEMIDLIST and then refresh to reflect the change on UI.
I must use notifications because if I've got opened more than one views of 
my NSE all these views should react correct to all changes in my NSE. The 
second reason is the folder tree view in Explorer. I don't know any way to 
refresh it except shell notifications.

> What interfaces have you implemented for IShellFolder?
        IPersistFolder2
        IShellFolderViewCB // also I tried to implement this interface in 
other class
        IContextMenu
        IShellFolder2
        IDropTarget
        IObjectWithSite


Thanks

"sunshine" wrote:

> Why you must use notification? you can manipulate you internal data to 
> modify ITEMIDLIST and then refresh to reflect the change on UI.
> 
> By the way, What interfaces have you implemented for IShellFolder?
> 
> url:http://www.ureader.com/msg/16601103.aspx
>
date: Mon, 10 Mar 2008 04:16:01 -0700   author:   Alexander

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us