Discussion:
FindFirstFile(), FindNextFile() and TreeView
(too old to reply)
Tomislav
20 years ago
Permalink
The user selects a directory, and my application searches that directory
for sub directories and then lists them in RichEdit with full path. For
searching directories I use FindFirstFile()and FindNextFile(). My
problem is that I want to use TreeView instead of RichEdit but I don't
know how add this directories to TreeView to show them like Windows
Explorer does.

For example when I select c:\ to search for sub directories

My RichEdit displays directories like this

c:\
c:\Folder 1
c:\Folder 1\Folder 1.1
c:\Folder 1\Folder 1.2
c:\Folder 2
c:\Folder 2\Folder 2.1
c:\Folder 2\Folder 2.2
c:\Folder 3
c:\Folder 3\Folder 3.1
c:\Folder 3\Folder 3.2

I would like TreeView to show found directories like this:

- c:\
- Folder 1
Folder 1.2
Folder 1.3
- Folder 2
Folder 2.1
Folder 2.2
+ Folder 3

My problem is the full path that is returned, I tried to extract the
directories with SubString that searches for "\\" and then I delete
everything before "\\" and after the next "\\" but I can't make it work.
Is my approach ok? How should I do this?
Thanks in advance.
Richard Bradbrook
20 years ago
Permalink
Don't reinvent the wheel, visit www.mustangpeak.net and download the
VirtualShellTools component package - it's free and has a treeview control.

(Note: The site seems down at this precise moment in time but I'm sure it'll
be fixed asap).
Tomislav
20 years ago
Permalink
Thanx, I didn't know about this component package. I'll download it as
soon as this site goes up again.
Post by Richard Bradbrook
Don't reinvent the wheel, visit www.mustangpeak.net and download the
VirtualShellTools component package - it's free and has a treeview control.
(Note: The site seems down at this precise moment in time but I'm sure it'll
be fixed asap).
Tomislav
20 years ago
Permalink
I've downloaded and installed components you suggested. First I've
installed Theme Manager, then VirtualTreeView and then VirtualShellTool.
Everything was compiled and installed ok, but when I put any of the
components on the form and try to compile I get following errors:

[C++ Error] uxtheme.h(176): E2146 Need an identifier to declare
[C++ Error] uxtheme.h(546): E2146 Need an identifier to declare
[C++ Error] VirtualShellTypes.hpp(30): E2451 Undefined symbol 'IDropTarget'
[C++ Error] VirtualShellTypes.hpp(30): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(30): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(31): E2451 Undefined symbol 'IQueryInfo'
[C++ Error] VirtualShellTypes.hpp(31): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(31): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(33): E2451 Undefined symbol
'IContextMenu3'
[C++ Error] VirtualShellTypes.hpp(33): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(33): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(35): E2451 Undefined symbol
'IAutoComplete'
[C++ Error] VirtualShellTypes.hpp(35): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(35): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(36): E2451 Undefined symbol
'IAutoComplete2'
[C++ Error] VirtualShellTypes.hpp(36): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(36): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(37): E2451 Undefined symbol 'IACList'
[C++ Error] VirtualShellTypes.hpp(37): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(37): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(38): E2451 Undefined symbol 'IACList2'
[C++ Error] VirtualShellTypes.hpp(38): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(38): E2040 Declaration terminated
incorrectly
[C++ Error] VirtualShellTypes.hpp(39): E2451 Undefined symbol
'ICurrentWorkingDirectory'
[C++ Error] VirtualShellTypes.hpp(39): E2299 Cannot generate template
specialization from 'DelphiInterface<T>'
[C++ Error] VirtualShellTypes.hpp(39): E2228 Too many error or warning
messages

I don't know what's wrong. If anyone could help I would be very thankful...
Post by Tomislav
Thanx, I didn't know about this component package. I'll download it as
soon as this site goes up again.
Post by Richard Bradbrook
Don't reinvent the wheel, visit www.mustangpeak.net and download the
VirtualShellTools component package - it's free and has a treeview control.
(Note: The site seems down at this precise moment in time but I'm sure
it'll be fixed asap).
Richard Bradbrook
20 years ago
Permalink
Go into Project Options -> Directories/Conditionals -> Conditionals

Add _WIN32_IE=0x0600 as a conditional define. (Anything above 0x0500 should
work though?!)

Other than that, it might be that you need a couple of newer header files -
i.e. those from the latest Micrsoft SDK etc.
Tomislav
20 years ago
Permalink
Sorry if I'm asking too much questions. I added _WIN32_IE=0x0600 as a
conditional define as you told me to, but that made no changes I'm still
receiving errors, but now only two of them:

[C++ Error] uxtheme.h(176): E2146 Need an identifier to declare
[C++ Error] uxtheme.h(546): E2146 Need an identifier to declare

Now if I understood you right I should download Microsoft .NET Framework
Version 2.0 Redistributable Package (x86) and/or .NET Framework 2.0
Software Development Kit(SDK)(x86).
Thank you on your effort on helping me.
Post by Richard Bradbrook
Go into Project Options -> Directories/Conditionals -> Conditionals
Add _WIN32_IE=0x0600 as a conditional define. (Anything above 0x0500 should
work though?!)
Other than that, it might be that you need a couple of newer header files -
i.e. those from the latest Micrsoft SDK etc.
Richard Bradbrook
20 years ago
Permalink
Hahaha, how can you say it made no changes if now you've only got 2 errors?!

If that's all you're getting, you don't need sdk - in any case, the .net sdk
wasn't the one I meant.
The Platform SDK would be the one you're after.

Double click on the error you see in the log. It'll take you to those lines
in the uxtheme.h file.

First is the THEMESIZE structure.

Edit it and format it as follows:

typedef enum THEMESIZE
{
TS_MIN, // minimum size
TS_TRUE, // size without stretching
TS_DRAW, // size that theme mgr will use to draw part
}THEMESIZE;

The second is the PROPERTYORIGIN structure.

Edit it and format it as follows:

typedef enum PROPERTYORIGIN
{
PO_STATE, // property was found in the state section
PO_PART, // property was found in the part section
PO_CLASS, // property was found in the class section
PO_GLOBAL, // property was found in [globals] section
PO_NOTFOUND // property was not found
} PROPERTYORIGIN;

Save that file and then recompile your project. It should work ok now.

Don't forget to add the 'ThemeManager' component to your main form btw.
That'll enable proper XP themes in your application and make the others work
properly (once you've also told them to allow themes via the properties - if
not enabled by default anyway).
Tomislav
20 years ago
Permalink
Thanks Richard on your effort I really apprechiate it. Everything works
fine now.
...
Jim
20 years ago
Permalink
Hi,
Post by Tomislav
[C++ Error] uxtheme.h(176): E2146 Need an identifier to declare
Did you read the BCB info file in the Docs folder <G>.


Issues with C++Builder 6

1) ThemeManager may not be put on the Include Path for the project
automatically.

Project > Options > Directories/Conditionals

Browse to the install path for

${ThemeManagerInstallPath}\Source

and add it to the list.

2) While here add NO_WIN32_LEAN_AND_MEAN to the conditional defines a
few controls down on the same tab.

3) The uxtheme.h file has bug in it. Replace the version that comes
with
C++Builder 6 with the supplied version.

${CBuilderINstallPath}\Include\uxtheme.h


Drop a VirtualExplorerTree component on a form and compile!

Enjoy,
Jim
--
www.mustangpeak.net
Tomislav
20 years ago
Permalink
Thank you very much Jim, now everything works fine.
...
Heinrich Wolf
20 years ago
Permalink
Hi,

have you already tried the Win31 Controls shipped with C++ Builder?
Here is a sample application without any code lines,
everything created by mouse click and setting properties in the Object
Inspector.

Regards
Heiner

MyFileOpenDlg.bpr
==============
<?xml version='1.0' encoding='utf-8' ?>
<!-- C++Builder XML Project -->
<PROJECT>
<MACROS>
<VERSION value="BCB.05.03"/>
<PROJECT value="MyFileOpenDlg.exe"/>
<OBJFILES value="MyFileOpenDlg.obj main.obj"/>
<RESFILES value="MyFileOpenDlg.res"/>
<DEFFILE value=""/>
<RESDEPEN value="$(RESFILES) main.dfm"/>
<LIBFILES value=""/>
<LIBRARIES value="VCLX50.lib bcbsmp50.lib VCL50.lib"/>
<SPARELIBS value="VCL50.lib bcbsmp50.lib VCLX50.lib"/>
<PACKAGES value="VCL50.bpi VCLX50.bpi bcbsmp50.bpi dclocx50.bpi
bcb2kaxserver50.bpi"/>
<PATHCPP value=".;"/>
<PATHPAS value=".;"/>
<PATHRC value=".;"/>
<PATHASM value=".;"/>
<DEBUGLIBPATH value="$(BCB)\lib\debug"/>
<RELEASELIBPATH value="$(BCB)\lib\release"/>
<LINKER value="tlink32"/>
<USERDEFINES value="_DEBUG"/>
<SYSDEFINES value="NO_STRICT"/>
<MAINSOURCE value="MyFileOpenDlg.cpp"/>
<INCLUDEPATH
value="C:\Programme\Borland\CBuilder5\Projects\;$(BCB)\include;$(BCB)\include\vcl"/>
<LIBPATH
value="C:\Programme\Borland\CBuilder5\Projects\;$(BCB)\lib\obj;$(BCB)\lib"/>
<WARNINGS value="-w-par"/>
</MACROS>
<OPTIONS>
<CFLAG1
value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi-
-c
-tW -tWM"/>
<PFLAGS value="-$YD -$W -$O- -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zd"/>
<LFLAGS value="-D&quot;&quot; -aa -Tpe -x -Gn -v"/>
</OPTIONS>
<LINKER>
<ALLOBJ value="c0w32.obj sysinit.obj $(OBJFILES)"/>
<ALLRES value="$(RESFILES)"/>
<ALLLIB value="$(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib"/>
</LINKER>
<IDEOPTIONS>
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
Locale=1031
CodePage=1252

[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=

[Debugging]
DebugSourceDirs=$(BCB)\source\vcl

[Parameters]
RunParams=
HostApplication=
RemoteHost=
RemotePath=
RemoteDebug=0

[Compiler]
ShowInfoMsgs=0
LinkDebugVcl=0
</IDEOPTIONS>
</PROJECT>

MyFileOpenDlg.cpp
==============
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
USERES("MyFileOpenDlg.res");
USEFORM("main.cpp", Form1);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->CreateForm(__classid(TForm1), &Form1);
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
//---------------------------------------------------------------------------

main.dfm
======
object Form1: TForm1
Left = 192
Top = 114
Width = 163
Height = 284
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DirectoryListBox1: TDirectoryListBox
Left = 4
Top = 24
Width = 145
Height = 97
FileList = FileListBox1
ItemHeight = 16
TabOrder = 0
end
object FileListBox1: TFileListBox
Left = 4
Top = 124
Width = 145
Height = 97
FileEdit = Edit1
ItemHeight = 13
TabOrder = 1
end
object DriveComboBox1: TDriveComboBox
Left = 4
Top = 4
Width = 145
Height = 19
DirList = DirectoryListBox1
TabOrder = 2
end
object Edit1: TEdit
Left = 4
Top = 224
Width = 121
Height = 21
TabOrder = 3
Text = '*.*'
end
end

main.h
=====
//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <FileCtrl.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TDirectoryListBox *DirectoryListBox1;
TFileListBox *FileListBox1;
TDriveComboBox *DriveComboBox1;
TEdit *Edit1;
private: // Anwender-Deklarationen
public: // Anwender-Deklarationen
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

main.cpp
=======
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "main.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
Loading...