Discussion:
IFolderView::GetFolder()
(too old to reply)
t***@gmail.com
2007-01-09 13:14:13 UTC
Permalink
Hi,

I am very new to NSE, and i am porting a NSE to vista.

I have NSE which is working fine in Vista also except Command Bar
items, i want to fill the Command bar, i know i need to implement
IShellFolder::CreateViewObject(IID_IExplorerCommandProvider), but to
trigger this we need to implement IFolderView. This IFolderView is not
implemented and my NSE is working fine with out this interface. now to
add Command Bar elements do i need to implement IFolderView completely
or just its GetFolder() method, Please Help me to implement this
method.



The NSE not implemented with Default implementation, Created using
custom IShellView and IFolderView implementations.

Thanks,
Gowda
Magnus
2007-01-09 13:59:44 UTC
Permalink
Post by t***@gmail.com
Hi,
I am very new to NSE, and i am porting a NSE to vista.
I have NSE which is working fine in Vista also except Command Bar
items, i want to fill the Command bar, i know i need to implement
IShellFolder::CreateViewObject(IID_IExplorerCommandProvider), but to
trigger this we need to implement IFolderView. This IFolderView is not
implemented and my NSE is working fine with out this interface. now to
add Command Bar elements do i need to implement IFolderView completely
or just its GetFolder() method, Please Help me to implement this
method.
The NSE not implemented with Default implementation, Created using
custom IShellView and IFolderView implementations.
Thanks,
Gowda
You do not need to implement any other method to get the explorer to
call your IExplorerCommandProvider but if you want to support the
"Organize" and "View" commands i guess you have to implement a few more
methods in the interface.

Regards
/Magnus
t***@gmail.com
2007-01-09 14:10:21 UTC
Permalink
Post by Magnus
You do not need to implement any other method to get the explorer to
call your IExplorerCommandProvider but if you want to support the
"Organize" and "View" commands i guess you have to implement a few more
methods in the interface.
Regards
/Magnus
Hi Magnus,

Thanks for your response,

Yes, i need to support "Organize" and "View". and also i need to add
few more new items to the command bar. could you please let me know
which are all the functions need to implement.

i tried to implement IFolderView::GetFolder(), but not getting it
right, could you tell me how to implement it,not getting a call in
CteateViewObject(IID_IExplorerCommandProvider").

Regards,
Gowda
Magnus
2007-01-09 14:28:24 UTC
Permalink
Post by t***@gmail.com
Yes, i need to support "Organize" and "View". and also i need to add
few more new items to the command bar. could you please let me know
which are all the functions need to implement.
I do not know exactly since i have not gone down that route but i guess
the methods that manipulates the viewmode and selectionstate must be
implemented at least.
Post by t***@gmail.com
i tried to implement IFolderView::GetFolder(), but not getting it
right, could you tell me how to implement it,not getting a call in
CteateViewObject(IID_IExplorerCommandProvider").
Regards,
Gowda
I think the requrement might be IFolderView2 and that it have to be
serviced trough IServiceProvider::QueryService().

Regards
/Magnus
Gowda
2007-01-10 08:14:51 UTC
Permalink
Hi Magnus,

To implement IFolderView::GetFolder(), i am getting only
GetFolder(IID_ExplorerPaneVisibility) calls. for no other riid this
function will be called. so i am confused what to do inside the
GetFolder() menthod. how do i need to implement it. my intesion is to
get IShellFolder::CreateViewObject(IID_ExplorerCommandProvider), so
that then i can fill up Command bar.

Regards,
Gowda
Magnus
2007-01-10 09:11:00 UTC
Permalink
Post by t***@gmail.com
Hi Magnus,
To implement IFolderView::GetFolder(), i am getting only
GetFolder(IID_ExplorerPaneVisibility) calls. for no other riid this
function will be called. so i am confused what to do inside the
GetFolder() menthod. how do i need to implement it. my intesion is to
get IShellFolder::CreateViewObject(IID_ExplorerCommandProvider), so
that then i can fill up Command bar.
Regards,
Gowda
Implement IExplorerPaneVisibility in your folder object.

Regards
Magnus
Gowda
2007-01-10 09:51:04 UTC
Permalink
Post by Magnus
Implement IExplorerPaneVisibility in your folder object.
Hi magnus,

But i guess no need of implementing IExplorerPaneVisibility to fill up
the Command bar. even i tried to implement it. but still i didn't get
the call CreateViewObject(IID_IExplorerCommandProvider).


Regards,
Gowda
Timo Partanen
2007-01-11 07:05:28 UTC
Permalink
Here is some information:

By implementing IExplorerPaneVisibility, you can get rid of the Organize and
Views commands (and even the whole command bar). Otherwise implementing
IExplorerPaneVisibility is not critical for any command bar integration.

As to your command bar problem, I guess your view object does not implement
IServiceProvider or it is not servicing SID_SFolderView. Right?

As you may already know, implementing IFolderView::Items is critical because
the command module is using that method to get a current selection in the
view as IShellItemArray. This array is further passed to various methods of
IExplorerCommand (e.g. IExplorercommand::GetState, IExplorerCommand::Invoke
etc.).

For implementing various subcommands (e.g. Copy, Cut, Properties etc.) of
the Organize command, your context menu (IContextMenu::InvokeCommand) must
be capable of executing each of these commands via the corresponding verb
(e.g. "copy" for Copy, "properties" for Properties etc.). Executing the
Rename subcommand goes via IFolderView2::DoRename. The Select All subcommand
is somewhat different. It requires your view object to implement
IShellFolderView::Select (with SFVS_SELECT_ALLITEMS) even though
IShellFolderView is deprecated.

You also need to implement IFolderView2 in your view object in order to put
the Views command of the command bar visible. The Views command is built up
with help of the IFolderView2::SetViewModeAndIconSize and
IFolderView2::GetViewModeAndIconSize methods of your view object.

Hope this helps.

Timo
Gowda
2007-01-13 11:59:01 UTC
Permalink
Post by Timo Partanen
As to your command bar problem, I guess your view object does not implement
IServiceProvider or it is not servicing SID_SFolderView. Right?
yes, you are right.
Post by Timo Partanen
Hope this helps.
Yes, Thanks Timo, i will look in to it.

Regards,
Gowda
Gowda
2007-01-22 10:28:52 UTC
Permalink
Hi Timo,
Post by Timo Partanen
By implementing IExplorerPaneVisibility, you can get rid of the Organize and
Views commands (and even the whole command bar). Otherwise implementing
IExplorerPaneVisibility is not critical for any command bar integration.
As to your command bar problem, I guess your view object does not implement
IServiceProvider or it is not servicing SID_SFolderView. Right?
I implemented IServiceProvider::QueryService(IID_FolderView) .

Explorer will call GetFolder() and SelectItem() functions of
IFolderViewImpl,but i couldn't complete it, because of follwing,


I Tried to implement IFolderView::GetFolder() method but the riid
parameter of this function will always have the value
IID_IExplorerPaneVisibility, as you sujjested i don't need to get rid
of Organize & View Commands, could you give some sample code to
implement this function.

after these two functions the Explorer will crash,

TIA
Regards,
Gowda
Timo Partanen
2007-01-23 20:33:04 UTC
Permalink
Post by Gowda
I implemented IServiceProvider::QueryService(IID_FolderView) .
Explorer will call GetFolder() and SelectItem() functions of
IFolderViewImpl,but i couldn't complete it, because of follwing,
I Tried to implement IFolderView::GetFolder() method but the riid
parameter of this function will always have the value
IID_IExplorerPaneVisibility, as you sujjested i don't need to get rid
of Organize & View Commands, could you give some sample code to
implement this function.
Sure, for example:

STDMETHODIMP CNSEView::GetFolder( REFIID riid, void** ppv )
{
// Check parameters.
if( !ppv )
return E_INVALIDARG;

// Reset out parameters.
*ppv = NULL;

// Query for the requested itf.
return m_pfolder->QueryInterface( riid, ppv );
}

In the code snippet above, m_pfolder is a member variable that points to the
folder object for which the view was created. The basic idea is to let the
folder choose which interfaces it implements.
Post by Gowda
after these two functions the Explorer will crash,
Sounds odd. Did you find a reason for that?
Gowda
2007-01-25 05:33:15 UTC
Permalink
Hi Timo,
Post by Timo Partanen
Sounds odd. Did you find a reason for that?
No, not exactly. Explorer will call the GetFolder() and SelectItem()
methods of IFolderViewImpl and then it will crash somewhere in explorer
code. here is sample code,

I implemented the IServiceProvider::QueryService() as below,

STDMETHODIMP CShellViewImpl::QueryService(REFGUID guidService, REFIID
riid, void **ppv)
{

if (IsEqualIID(guidService, SID_SFolderView))
{

IFolderView *pIFolderView = NULL;
HRESULT hr = CComCreator< CComObject< CFolderViewImpl >
Post by Timo Partanen
::CreateInstance(NULL, IID_IFolderView, (LPVOID *)&pIFolderView);
if (FAILED(hr))
return hr;

// Return the view to the caller
*ppv = (void *)pIFolderView;
return S_OK;

}

*ppv = NULL;
return E_NOINTERFACE;

}

and I implemented IFolderViewImpl::GetFolder() as you given the sample
code, and in the IFolderViewImpl::SelectItem() i will select the
specified item using list view control function,

ListView_SetItemState(m_hWndListControl, iIndex, LVIS_SELECTED,
LVIS_SELECTED);

index is the parameter of the SelectItem() method.
But if I implement IFolderview in IShellViewImpl then explorer will
call only GetFolder() method, but no crash.

did I missed something?

TIA
Gowda
Timo Partanen
2007-01-25 08:58:53 UTC
Permalink
Post by Gowda
STDMETHODIMP CShellViewImpl::QueryService(REFGUID guidService, REFIID
riid, void **ppv)
{
if (IsEqualIID(guidService, SID_SFolderView))
{
IFolderView *pIFolderView = NULL;
HRESULT hr = CComCreator< CComObject< CFolderViewImpl >
Post by Timo Partanen
::CreateInstance(NULL, IID_IFolderView, (LPVOID *)&pIFolderView);
if (FAILED(hr))
return hr;
// Return the view to the caller
*ppv = (void *)pIFolderView;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
Is there any reason to implement the IFolderView interface on a separate
object? Based on my understanding, if a Shell view is asked for the
SID_SFolderView service via IServiceProvider::QueryService, it should return
an interface pointer to itself. And as you mentioned, when you did that way
you did not have any problems either.
Gowda
2007-01-30 13:09:08 UTC
Permalink
Thanks a lot Timo, I could see the "Organize" and "View" buttons on my
NSE command bar :-)

But few more Q's

In "Views" command bar item, where do we need to handle the view
change? is there any way to customize the "views" command, because I
want to support only stardard four views(not thumbnail & scrolling)?

To implement the IFolderView::Items(IID_IShellItemArray), do I need to
implement its all methods or the could I use
SHCreateShellItemArrayFromIDLists() or SHCreateShellItemArray ()
method?

And what are the interfaces and functions I need to implement along
with IExplorerCommand, if i want to add a new item(Application
related) to the command bar?

TIA
Regards,
Gowda
Timo Partanen
2007-01-31 18:24:39 UTC
Permalink
Post by Gowda
In "Views" command bar item, where do we need to handle the view
change? is there any way to customize the "views" command, because I
want to support only stardard four views(not thumbnail & scrolling)?
What do you mean by the "view change"? I do not know any way of customizing
or limiting its subcommands.
Post by Gowda
To implement the IFolderView::Items(IID_IShellItemArray), do I need to
implement its all methods or the could I use
SHCreateShellItemArrayFromIDLists() or SHCreateShellItemArray ()
method?
The point is to use either SHCreateShellItemArrayFromIDLists,
SHCreateShellItemArray or some other that creates an instance of the
standard shell item array of Shell.
Post by Gowda
And what are the interfaces and functions I need to implement along
with IExplorerCommand, if i want to add a new item(Application
related) to the command bar?
This was discussed here a while ago under the topic "How to fill the command
bar in Vista?"

Regards,
Timo
Gowda
2007-02-02 06:59:24 UTC
Permalink
Hi Timo.
Post by Timo Partanen
The point is to use either SHCreateShellItemArrayFromIDLists,
SHCreateShellItemArray or some other that creates an instance of the
standard shell item array of Shell.
I couldn't find any document or example in msdn to create an instance
of the standard shell item array of Shell using IShellItemArray or any
of thse functions. could you please give me some sample code to
implement IFolderView::Items(IID_IShellItemArray).
Post by Timo Partanen
This was discussed here a while ago under the topic "How to fill the command
bar in Vista?"
Yes, I gone through that Discussion. but I struck with the
implementation of IEnumExplorerCommand::Next() method to fill the new
item to the command bar. Please any document or the sample code for
the same.

TIA
Regards,
Gowda
Timo Partanen
2007-02-07 06:15:27 UTC
Permalink
Post by Gowda
I couldn't find any document or example in msdn to create an instance
of the standard shell item array of Shell using IShellItemArray or any
of thse functions. could you please give me some sample code to
implement IFolderView::Items(IID_IShellItemArray).
Here is a simple code snippet:

// Set this to the ID list of the parent folder...
LPCITEMIDLIST pidlParent = NULL;

// Set this to a child item ID...
LPCITEMIDLIST pidlChild = NULL;

// Create a shell item array.
IShellItemArray* psia = NULL;
HRESULT hr = SHCreateShellItemArray( pidlParent, NULL, 1, &pidlChild,
&psia );

If you are not building against the latest Platform SDK, you must retrieve
the address of SHCreateShellItemArray from Shell32.dll by using the
GetProcAddress Win32 API function.

Information on SHCreateShellItemArray:
http://msdn2.microsoft.com/en-us/library/ms647723.aspx
Post by Gowda
Yes, I gone through that Discussion. but I struck with the
implementation of IEnumExplorerCommand::Next() method to fill the new
item to the command bar. Please any document or the sample code for
the same.
Did you manage to get it work? Probably you have provided a similar kind of
enumerator (IEnumIDList) for your ID-lists to implement
IShellFolder::EnumObjects. For IEnumExplorerCommand, you just need to
provide IExplorerCommand itfs instead of LPITEMIDLISTs.

Cheers,
Timo
Gowda
2007-02-07 08:59:59 UTC
Permalink
Hi Timo,
Post by Timo Partanen
// Set this to the ID list of the parent folder...
LPCITEMIDLIST pidlParent = NULL;
// Set this to a child item ID...
LPCITEMIDLIST pidlChild = NULL;
// Create a shell item array.
IShellItemArray* psia = NULL;
HRESULT hr = SHCreateShellItemArray( pidlParent, NULL, 1, &pidlChild,
&psia );
There is a uFlags argument in IFolderView::items(UINT uFlags, REFIID
riid, void **ppv); function, i think according uFlags value we need
to create ShellItemArray, but i have some problems getting child and
parent PIDLs for the respective uFlags value. any help regarding
this.
Post by Timo Partanen
Did you manage to get it work? Probably you have provided a similar kind of
enumerator (IEnumIDList) for your ID-lists to implement
IShellFolder::EnumObjects. For IEnumExplorerCommand, you just need to
provide IExplorerCommand itfs instead of LPITEMIDLISTs.
NO. i'm still working around these issues. can you give me some sample
code?.
Post by Timo Partanen
Cheers,
Timo
TIA
Regards,
Gowda
Timo Partanen
2007-02-07 12:23:42 UTC
Permalink
Post by Gowda
There is a uFlags argument in IFolderView::items(UINT uFlags, REFIID
riid, void **ppv); function, i think according uFlags value we need
to create ShellItemArray, but i have some problems getting child and
parent PIDLs for the respective uFlags value. any help regarding
this.
That is true. Based on uFlags, you must determine which ID-lists to return.
For SVGIO_SELECTION, you must return selected items only. For SVGIO_ALLVIEW,
you must return all items in the view. Your view object should know the
absolute ID-list of the parent folder so creating a shell item array based
on the parent ID-list and the chosen ID-lists in the view should be
possible.
Post by Gowda
NO. i'm still working around these issues. can you give me some sample
code?.
I am using the ATL::IEnumOnSTLImpl template class to implement
IEnumExplorerCommand. It is available in ATL at least when using Visual
Studio .NET 2003. Can you use IEnumOnSTLImpl? At least you can check how
IEnumOnSTLImpl implements the Next method. You can also post your
IEnumExplorerCommand implementation here so we can look at it together.

Regards,
Timo
Gowda
2007-02-08 12:16:27 UTC
Permalink
Hello Timo,
Post by Timo Partanen
That is true. Based on uFlags, you must determine which ID-lists to return.
For SVGIO_SELECTION, you must return selected items only. For SVGIO_ALLVIEW,
you must return all items in the view. Your view object should know the
absolute ID-list of the parent folder so creating a shell item array based
on the parent ID-list and the chosen ID-lists in the view should be
possible.
Ok, i ll Try this.
Post by Timo Partanen
I am using the ATL::IEnumOnSTLImpl template class to implement
IEnumExplorerCommand. It is available in ATL at least when using Visual
Studio .NET 2003. Can you use IEnumOnSTLImpl?
I'm Using Visual Studio .Net 2005 prof.
Post by Timo Partanen
At least you can check how
IEnumOnSTLImpl implements the Next method. You can also post your
IEnumExplorerCommand implementation here so we can look at it together.
I just return E_NOTIMPL from all the IEnumExplorerCommand methods, Can
you give me Sample code for this implementation?


TIA,
Regards,
Gowda

Loading...