<HTML><HEAD><TITLE>Views</TITLE>
</HEAD>
<body bgcolor="ffffdd">
<table width="100%" cellpadding=3 cellspacing=0>
<tr>
<td> </td>
</tr>
<tr>
<td valign=top bgcolor="#e0e0e0"><font face="Verdana, Arial, Helvetica" color="#880000">
<b>Windows Explorer like application</b>
</font>
</td>
</tr>
<tr>
<td valign=top bgcolor="#f0f0f0">
<font size=2 face="Arial" color="#000000">
<ul>
<LI><b>Brief Intro</b></LI>
</ul></font>
<BLOCKQUOTE>
This article creates an
application which is similar to Windows Explorer. This article
does not only display the directory and files but also displays
icons of the respective file types as is displayed in Windows
Explorer. If you select Windows Explorer instead of MFC Standard
in in AppWizard's step 5 dialog box, AppWizard adds code to
create a static splitter window. It also derives a pair of view
classes-one from <EM>CTreeView</EM> (<EM>CLeftView</EM>), the other from <EM>CListView</EM> (<EM>CExplorerView</EM>) or the view class of your choice-and
places them in the splitter window's panes. Despite the outward
similarities between this application and the Windows Explorer,
there is a fundamental difference between these applications. My
application displays only the drives, directory and the files
and not the desktop, My Computer etc.
</BLOCKQUOTE>
<BLOCKQUOTE><STRONG>The
Tree View
</STRONG>
</BLOCKQUOTE>
<BLOCKQUOTE>
In <EM>OnInitialUpdate( )</EM> handler of <EM>CLeftView, AddDrives( )</EM> function is called to insert
all the drives in the tree control.
<EM>Adddirectories( )</EM> function gets called when user
double clicks on the item of the tree view control to expand the
tree. the <EM>DeleteFirstChild( )</EM> and <EM>DeleteAllChildren( )
</EM>functions are
called at the time of collapsing the tree.
</BLOCKQUOTE>
<BLOCKQUOTE><STRONG>The
List View Control
</STRONG>
</BLOCKQUOTE>
<BLOCKQUOTE>
The items in the list view
control are added in the <EM>Refresh( )</EM>
function.
<EM>Refresh( )</EM> function is
called each time when the view is updated. In <EM>OnInitialUpdate( ) </EM>function two image lists (one for
small view and other for large view) are created to which items
will be added dynamically. Three columns namely FileName, Size
and Last Modified have been inserted. A function createlist is
called to add the images to the image lists. The number of
images to be added to the list depends upon the type of files (
c, c++, jpg, gif, asp etc) in your machine. Since list has to be
created dynamically nobody can gase the number of images in the
list. Hence an object of CObArray has been created. Windows
displays different icons for the different file types. I have
tried to get the icons of maximum types of files from the
registry and display it against that file. Reading the file
extension, retrieving the default icon for the file and storing
it in the array is a bit complicated task. I have followed the
following steps to reach to the default icon:
</BLOCKQUOTE>
<BLOCKQUOTE>
(a) Read all those sub-keys of
HKEY_CLASSES_ROOT key that are the extensions of files <BR>(b) The default value of these keys happens
to be the subkey of HKEY_CLASSES_ROOT <BR>(c) This key has a sub-key called DefaultIcon. <BR>(d) The default value of DefaultIcon key is
the path of exe file and index of the icon.
</BLOCKQUOTE>
<BLOCKQUOTE>
Once the path and number is
received the icon is extracted using <EM>::ExtractIcon( )</EM> function and is added to the list. In
case of some files like .exe, .ico, .cur they have their own
icons. Icons of these files are read in <EM>AddItem( ) </EM>function. Some of the .exe files do not
possess their own icon. Such files get 0th icon of shell32.dll
file (logo of Windows). Similarly the files for which no icons
are found after following the above mentioned steps the same
icon (logo of Windows) is given. However there is a limitation.
If the default icons are retrieved by following the above
mentioned way we don't get icons for some of the files. If
anyone knows a better way to display the icons please contact me
at kanet@nagpur.dot.net.in
</BLOCKQUOTE>
<UL>
<BR><CENTER><IMG SRC="explorer.gif" width="480" height="268">
</CENTER><BR>
</UL>
<UL><A HREF="explorer.zip">Download</A> </UL></FONT></td>
</tr>
</table>
<BR>
</body>
</HTML>