IFileDialog-刷新文件列表 [英] IFileDialog - refreshing file listings

查看:78
本文介绍了IFileDialog-刷新文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用新文件对话框,其中包含相当长的文件类型列表.使用SetFileTypes()方法既简单又实用,但是在显示显示扩展名"时却显示了我冗长而丑陋的扩展名列表.在资源管理器中设置.因此,我希望使用SetFilter()方法制作元过滤器.

我的IShellItemFilters可以单独正常工作,但是当用户使用时,我无法弄清楚如何使用新的过滤器刷新对话框更改选定的文件类型.与IFileDialogEvents :: OnTypeChange挂钩可以让我知道何时发生并重置-是否有任何api或技巧可以刷新对话框UI?

(或者,对于我最初发布的令人不快的SetFileTypes输出,也有任何建议欢迎...)最好,迈克尔·迈克尔,我的测试代码的一部分-一个模糊的想法...

class Filter1:public IShellItemFilter {
virtual HRESULT STDMETHODCALLTYPE IncludeItem(IShellItem * item){
return S_OK;
}
};

class Filter2:公共IShellItemFilter {
virtual HRESULT STDMETHODCALLTYPE IncludeItem(IItem * item){
SFGAOF属性= 0; {
传回S_FALSE;
};

Filter1 f1;
Filter2 f2;

class FDE:public IFileDialogEvents {<: > HRESU LT STDMETHODCALLTYPE OnTypeChange(IFileDialog *对话框){ fileType = 0;
对话框-> GetFileTypeIndex(& fileType);
如果(fileType == 1){<(f1);
}其他{
dialog-> setFilter(f2);
返回s_OK;
}


I am using the new file dialogs with a rather long list of filetypes.  Using the SetFileTypes() method is easy and functional, but shows my long, ugly list of extensions when "show extensions" is set in explorer.  So I'm hoping to make meta-filters using the SetFilter() method.

My IShellItemFilters are working fine individually, but I can't figure out how to make the dialog refresh with a new filter when the user changes the selected file type.  Hooking into IFileDialogEvents :: OnTypeChange allows me to know when this happens and reset--is there any api or trick for refreshing the dialog UI?

(Alternatively, any suggestions to my original issue of unpleasant SetFileTypes output are also welcome...)

Best,
Michael

--- a portion of my test code for a vague idea...

class Filter1 : public IShellItemFilter {
    virtual HRESULT STDMETHODCALLTYPE IncludeItem(IShellItem* item) {
        return S_OK;
    }
};

class Filter2 : public IShellItemFilter {
    virtual HRESULT STDMETHODCALLTYPE IncludeItem(IShellItem* item) {
        SFGAOF attributes = 0;
        item->GetAttributes(SFGAO_FOLDER, &attributes);
        if (attributes & SFGAO_FOLDER) {
            return S_OK;
        } else {
            return S_FALSE;
        }                 
};

Filter1 f1;
Filter2 f2;

class FDE : public IFileDialogEvents {
    public:
    HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog* dialog) {
        UINT fileType = 0;
        dialog->GetFileTypeIndex(&fileType);
        if (fileType == 1) {
            dialog->setFilter(f1);
        } else {
            dialog->setFilter(f2);
        }
        return S_OK;
    }
    <snip other methods>
};

推荐答案

另一个盲区:调用

SHChangeNotify(SHCNE_UPDATEDIR,SHCNF_PATH,folderName,NULL);

似乎没有刷新视图.如果有一种方法可以从IFileDialog下面抓取一个IShellView对象(似乎很可能在那里),我认为IShellView :: Refresh()方法将是一个不错的选择...
Another blind alley: calling

SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_PATH, folderName, NULL);

doesn't appear to refresh the view.  If there is a way to grab an IShellView object from below the IFileDialog (it seems like one may well be there), I think the IShellView :: Refresh() method would be a good choice...


这篇关于IFileDialog-刷新文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆