In my shell extension, I want to mimic explorer's behavior and show 'This folder is empty' message when in fact my folder is empty:
However, I can't accomplish it.
Using API Monitor, I see that when explorer refreshes an empty folder, IEnumIDList::Next()
is returning the following:
Meaning, that the 'next' item returned is NULL
, the number of items is 0
and the result is S_FALSE
.
As mentioned, I tried to mimic the return values, and indeed no items are loaded for the folder, but no message appear either.
So what API would trigger this message?
Your IEnumIDList implementation must implement IObjectWithSite. Sample of implementation:
var
ServiceProvider: IServiceProvider;
ShellBrowser: IShellBrowser;
ShellView: IShellView;
FolderView2: IFolderView2;
begin
if not Assigned(ASite) then Exit;
OleCheck(ASite.QueryInterface(IServiceProvider, ServiceProvider));
try
OleCheck(ServiceProvider.QueryService(SID_STopLevelBrowser, IShellBrowser, ShellBrowser));
try
OleCheck(ShellBrowser.QueryActiveShellView(ShellView));
try
OleCheck(ShellView.QueryInterface(IFolderView2, FolderView2));
try
FolderView2.SetText(FVST_EMPTYTEXT, 'The message you want to see');
finally
FolderView2 := nil;
end;
finally
ShellView := nil;
end;
finally
ShellBrowser := nil;
end;
finally
ServiceProvider := nil;
end;
end;
Result:
Also you can use the same code in your IShellFolder implementation.