wxListCtrl set application icon
wxListCtrl set application icon
I am going to use wxListCtrl http://docs.wxwidgets.org/trunk/classwx_list_ctrl.html in order to list directory files.
List has been created successfully. And now i am going to show file's icon. I have set icon with wxArtProvider http://docs.wxwidgets.org/trunk/classwx ... vider.html, and have got result as shown below: But my goal is to display icons as shown on screenshot below: How can i do this? Thanks.
List has been created successfully. And now i am going to show file's icon. I have set icon with wxArtProvider http://docs.wxwidgets.org/trunk/classwx ... vider.html, and have got result as shown below: But my goal is to display icons as shown on screenshot below: How can i do this? Thanks.
Re: wxListCtrl set application icon
I think you should get icons from something like wxTheMimeTypesManager->GetFileTypeFromExtension("pdf")->GetIcon(...);
..but do check against NULL returned wxFileType.
..but do check against NULL returned wxFileType.
Re: wxListCtrl set application icon
Unfortunately, using wxWidgets methods (see wxFileCtrl or wxDirCtrl) for extracting icons on MSW won't probably provide user experience comparable with native shell view available through e.g. Windows Explorer or IFileDialog (obtained with SHGetFileInfo()). For example, no overlay icons. OTOH, most users probably never saw an overlay icon once in their life (except for the link overlays)...
Re: wxListCtrl set application icon
@Oleg: I hope you knew about wxFileCtrl and didn't duplicate all its functionality.
http://docs.wxwidgets.org/trunk/classwx_file_ctrl.html
@PB: I know you worked on IFileDialog. Would a native wxFileCtrl/wxDirCtrl be possible?
http://docs.wxwidgets.org/trunk/classwx_file_ctrl.html
@PB: I know you worked on IFileDialog. Would a native wxFileCtrl/wxDirCtrl be possible?
Use the source, Luke!
Re: wxListCtrl set application icon
Sorry, I know nothing about shell programming. implementing wxDirDialog with IFileDialog was very simple, just wrapping few API calls.doublemax wrote:@PB: I know you worked on IFileDialog. Would a native wxFileCtrl/wxDirCtrl be possible?
To create a native MSW wxFileCtrl/wxDirCtrl, I think one would have to implement/wrap IShellBrowser or IFolderView or IShellView or something similar. While this seems not difficult, it probably is still non-trivial.
But perhaps at least just implementing the native MSW icons including overlays would be a step in a right direction. The question is, how many people actually use those two controls, instead of using the respective common dialogs.
Re: wxListCtrl set application icon
Is it possible to create something like that? Note. I need not to create file/directory chooser dialog. I need to create a list of file like it does TotalCommander. So it is possible with wxFileCtrl? Thanks.doublemax wrote:@Oleg: I hope you knew about wxFileCtrl and didn't duplicate all its functionality.
http://docs.wxwidgets.org/trunk/classwx_file_ctrl.html
Re: wxListCtrl set application icon
Yes, that's what wxFileCtrl does. Check the "widgets" sample that comes with wxWidgets to see it in action.Note. I need not to create file/directory chooser dialog. I need to create a list of file like it does TotalCommander. So it is possible with wxFileCtrl? Thanks
Use the source, Luke!
Re: wxListCtrl set application icon
AFAIK the icons themselves should be identical to Explorer. Just without the overlays. I don't see the missing overlays as a real problem though.But perhaps at least just implementing the native MSW icons including overlays would be a step in a right direction.
Use the source, Luke!
Re: wxListCtrl set application icon
So, i built sample. And now a have next question: Is it possible to add additional columns to wxFileCtrl like (ext, date etc..)? and remove fields shown on screenshot?
I do not see any options or styles in order to do that.Re: wxListCtrl set application icon
I'm afraid not.And now a have next question: Is it possible to add additional columns to wxFileCtrl like (ext, date etc..)? and remove fields shown on screenshot?
Use the source, Luke!
Re: wxListCtrl set application icon
As an option i think i can use wxGenericDirCtrl http://docs.wxwidgets.org/trunk/classwx ... _ctrl.html but this control also does not support additional colums. So, i guess it is better to use wxListCtrl. Guys, what do you think about this?
Re: wxListCtrl set application icon
Depends on how far you already are with your solution. If you're almost done, go with it. Otherwise you could try to just copy the whole wxGenericDirCtrl file into your project, rename the class and all references and use that as a basis for your modifications.i guess it is better to use wxListCtrl. Guys, what do you think about this?
Use the source, Luke!
Re: wxListCtrl set application icon
Looks like it is better to use wxListCtrl for me. Will solve icon issue as @catalin told.
catalin wrote:I think you should get icons from something like wxTheMimeTypesManager->GetFileTypeFromExtension("pdf")->GetIcon(...);
..but do check against NULL returned wxFileType.
Re: wxListCtrl set application icon
Hi, guys.
I am trying use system icon in this way (as @catalin told.)
This is my code:
But GUI is loaded i get this error dialog:
Code has been debugged and there is no error. It shows only when GUI is loaded.
What am i doing wrong?
I am trying use system icon in this way (as @catalin told.)
This is my code:
Code: Select all
wxArrayString arr;
wxTheMimeTypesManager->EnumAllFileTypes(arr);
wxImageList* imageList = new wxImageList(16, 16);
imageList->Add(wxArtProvider::GetIcon(wxART_GO_TO_PARENT)); // index = 0;
imageList->Add(wxArtProvider::GetIcon(wxART_FOLDER)); // index = 1;
imageList->Add(wxArtProvider::GetIcon(wxART_EXECUTABLE_FILE)); // index = 2;
for (const wxString& mime : arr)
{
wxSharedPtr<wxFileType> ft(wxTheMimeTypesManager->GetFileTypeFromMimeType(mime));
if (!ft)
continue;
wxIconLocation iconLoc;
if (!ft->GetIcon(&iconLoc))
continue;
wxArrayString exts;
if (!ft->GetExtensions(exts))
continue;
wxIcon icon(iconLoc);
int extIndex = imageList->Add(icon);
for (const wxString& ext : exts)
{
extMap_.insert(ExtHashMap::value_type(ext, extIndex));
}
}
SetImageList(imageList, wxIMAGE_LIST_SMALL);
What am i doing wrong?
Re: wxListCtrl set application icon
Code: Select all
wxIcon icon(iconLoc);
Besides, i'm not sure it's a good idea to get the icons for *all* mimetypes at once. Especially on old Windows systems there may be many zombie entries in the registry. Before you start optimizing your code, i'd suggest to get the icon for each file individually. Of course you always need a fallback icon for the case that the retrieval fails.
Use the source, Luke!