Browse Source

Fix for win32 file icon extraction.

tags/2021-05-28
Julian Storer 13 years ago
parent
commit
5fc80a9b79
4 changed files with 40 additions and 27 deletions
  1. +21
    -20
      extras/JuceDemo/Source/demos/TreeViewDemo.cpp
  2. +7
    -3
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp
  3. +1
    -0
      modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h
  4. +11
    -4
      modules/juce_gui_basics/native/juce_win32_Windowing.cpp

+ 21
- 20
extras/JuceDemo/Source/demos/TreeViewDemo.cpp View File

@@ -125,7 +125,7 @@ public:
const String treeXmlString (BinaryData::treedemo_xml);
XmlDocument parser (treeXmlString);
treeXml = parser.getDocumentElement();
jassert (treeXml != 0);
jassert (treeXml != nullptr);
}
rootItem = new TreeViewDemoItem (*treeXml);
@@ -150,28 +150,29 @@ public:
~TreeViewDemo()
{
fileTreeComp = 0;
directoryList = 0; // (need to make sure this is deleted before the TimeSliceThread)
treeView = nullptr;
fileTreeComp = nullptr;
directoryList = nullptr; // (need to make sure this is deleted before the TimeSliceThread)
}
void paint (Graphics& g)
{
g.setColour (Colours::grey);
if (treeView != 0)
if (treeView != nullptr)
g.drawRect (treeView->getX(), treeView->getY(),
treeView->getWidth(), treeView->getHeight());
if (fileTreeComp != 0)
if (fileTreeComp != nullptr)
g.drawRect (fileTreeComp->getX(), fileTreeComp->getY(),
fileTreeComp->getWidth(), fileTreeComp->getHeight());
}
void resized()
{
if (treeView != 0)
if (treeView != nullptr)
treeView->setBoundsInset (BorderSize<int> (40, 10, 10, 10));
else if (fileTreeComp != 0)
else if (fileTreeComp != nullptr)
fileTreeComp->setBoundsInset (BorderSize<int> (40, 10, 10, 10));
typeButton.changeWidthToFitText (22);
@@ -180,8 +181,8 @@ public:
void showCustomTreeView()
{
treeView = 0;
fileTreeComp = 0;
treeView = nullptr;
fileTreeComp = nullptr;
addAndMakeVisible (treeView = new TreeView());
treeView->setRootItem (rootItem);
@@ -192,8 +193,8 @@ public:
void showFileTreeComp()
{
treeView = 0;
fileTreeComp = 0;
treeView = nullptr;
fileTreeComp = nullptr;
addAndMakeVisible (fileTreeComp = new FileTreeComponent (*directoryList));
resized();
@@ -206,11 +207,11 @@ public:
m.addItem (2, "FileTreeComponent showing the file system");
m.addSeparator();
m.addItem (3, "Show root item", true,
treeView != 0 ? treeView->isRootItemVisible()
: fileTreeComp->isRootItemVisible());
treeView != nullptr ? treeView->isRootItemVisible()
: fileTreeComp->isRootItemVisible());
m.addItem (4, "Show open/close buttons", true,
treeView != 0 ? treeView->areOpenCloseButtonsVisible()
: fileTreeComp->areOpenCloseButtonsVisible());
treeView != nullptr ? treeView->areOpenCloseButtonsVisible()
: fileTreeComp->areOpenCloseButtonsVisible());
m.showMenuAsync (PopupMenu::Options().withTargetComponent (&typeButton),
ModalCallbackFunction::forComponent (menuItemChosenCallback, this));
@@ -218,7 +219,7 @@ public:
static void menuItemChosenCallback (int result, TreeViewDemo* demoComponent)
{
if (demoComponent != 0)
if (demoComponent != nullptr)
demoComponent->menuItemChosenCallback (result);
}
@@ -234,16 +235,16 @@ public:
}
else if (result == 3)
{
if (treeView != 0)
if (treeView != nullptr)
treeView->setRootItemVisible (! treeView->isRootItemVisible());
else
else if (fileTreeComp != nullptr)
fileTreeComp->setRootItemVisible (! fileTreeComp->isRootItemVisible());
}
else if (result == 4)
{
if (treeView != 0)
if (treeView != nullptr)
treeView->setOpenCloseButtonsVisible (! treeView->areOpenCloseButtonsVisible());
else
else if (fileTreeComp != nullptr)
fileTreeComp->setOpenCloseButtonsVisible (! fileTreeComp->areOpenCloseButtonsVisible());
}
}


+ 7
- 3
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.cpp View File

@@ -37,7 +37,7 @@ DirectoryContentsList::DirectoryContentsList (const FileFilter* const fileFilter
DirectoryContentsList::~DirectoryContentsList()
{
clear();
stopSearching();
}
void DirectoryContentsList::setIgnoresHiddenFiles (const bool shouldIgnoreHiddenFiles)
@@ -88,12 +88,16 @@ void DirectoryContentsList::setTypeFlags (const int newFlags)
}
}
void DirectoryContentsList::clear()
void DirectoryContentsList::stopSearching()
{
shouldStop = true;
thread.removeTimeSliceClient (this);
fileFindHandle = nullptr;
}
void DirectoryContentsList::clear()
{
stopSearching();
if (files.size() > 0)
{


+ 1
- 0
modules/juce_gui_basics/filebrowser/juce_DirectoryContentsList.h View File

@@ -200,6 +200,7 @@ private:
ScopedPointer <DirectoryIterator> fileFindHandle;
bool volatile shouldStop;
void stopSearching();
void changed();
bool checkNextFile (bool& hasChanged);
bool addFile (const File& file, bool isDir,


+ 11
- 4
modules/juce_gui_basics/native/juce_win32_Windowing.cpp View File

@@ -2874,13 +2874,20 @@ void Desktop::getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords
}
//==============================================================================
Image juce_createIconForFile (const File& file)
static HICON extractFileHICON (const File& file)
{
Image image;
WORD iconNum = 0;
WCHAR name [MAX_PATH * 2];
file.getFullPathName().copyToUTF16 (name, sizeof (name));
return ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(),
name, &iconNum);
}
HICON icon = ExtractAssociatedIcon ((HINSTANCE) Process::getCurrentModuleInstanceHandle(),
const_cast <WCHAR*> (file.getFullPathName().toWideCharPointer()), &iconNum);
Image juce_createIconForFile (const File& file)
{
Image image;
HICON icon = extractFileHICON (file);
if (icon != 0)
{


Loading…
Cancel
Save