Home of Shell MegaPack : Windows Explorer-Like File & Folder Browser Controls & Components For .Net & ActiveX

FolderView ActiveX Control How-To Guide

Categories

Installation
Deployment and distribution
Licensing and registration
Usage in web development
Customization ( custom icons, custom displaytexts, custom items, etc..)
Behavior control ( e.g. prevent opening of files)
Filtering ( e.g. show only files)
General - programmatic control

*In this guide the terms folder, file, TreeNode, node and item are used interchangeably.


Installation

How can my development project start using a new version of the control ?

After you install a new version of FolderView ActiveX Control, applications you have developed do not retain their saved properties and licensing information. To use the new version properly in your applications, you should perform the following steps :

1. Delete and reinsert the control on the form(and give the reinserted control the original name, so that your code continues to work).
2. Set the properties of the control to your original properties.
3. Rebuild the development project ( The control will not save properties properly if you just issue the build command; you have to issue the Rebuild All command ).


How can I register the FolderView ActiveX Control on my system?

Before any ActiveX control can be used, proper information about the control must be entered in the system registry. This process is called as 'registering' the control. Normally FolderView ActiveX Control is automatically registered on your system, when you install it. If you need to register the control again, for example if it becomes unregistered for some reason and you cannot see it in the 'Insert ActiveX Control' dialog box, then you can just reinstall the control again. Alternatively you can quickly register the control by dragging and dropping the fldrvw70.ocx file on the regsvr32.exe file that is present in the Windows System directory.


Deployment and distribution

What are the procedures for distributing FolderView ActiveX Control with my application?

An application which uses FolderView ActiveX Control should distribute the file fldrvw70.ocx along with the dependencies listed above. No other information or files is necessary for distribution. The developer should make sure that the control is registered in the system registry on the end-users' machines. Registration of the control is done automatically by many installation builders during installation of your program, or you can do the registration yourself during the installation of your program. The redistributable file regsvr32.exe can be used for control registration. This registration is required for every ActiveX control to run on a machine.

Note that the above registration is different from 'registering the control', that is entering the registration codes ( username and code ) after you have purchased the control. This registration should only be done on the developers' machines after you have purchased the licenses for the control. Under no circumstances should the developer make available to the end-user or their systems, the sensitive registration and licensing information ( username and codes ) either explicitly or implicitly. Please read the License Agreement for further information. The FolderView ActiveX Control handles registration and licensing by embedding the developer's license information in the application. When this application is run, this information is automatically retrieved and verified if the control is licensed.


The end-users of my program get one of the following error messages when they run the program :
"Runtime error 429: you don't have the appropriate license to use this functionality"
"Run-time error '13': Type mismatch"

This problem can occur if your program uses FolderView v4.3 or earlier, because all these versions of FolderView had the same GUID and a filename of fldrview.ocx. The problem occurs because the different versions of FolderView are not binary compatible with each other. Your program might be compiled with one version of FileView and the end-user might have a different version. This can happen if the end-user installs another program which uses a different versions of FolderView. In this case, the version of FolderView that comes with the other program will replace the one that your program uses.

Till version 4.3, all versions of FolderView had the same GUID and a filename of fldrview.ocx. However, starting with version 5.0, each version has a different GUID and filename ( e.g. v5.0 has a filename of fldrvw50.ocx ). This ensures that multiple versions of FolderView can coexist on the same machine.

Therefore, if your program uses FolderView v5.0 or above, then you wont have this problem. However, if your program uses earlier versions, then the only way to solve the problem on the end-user's machine is to make sure that his machine has only one version of FolderView installed and that version is the same version that your program uses. To ensure that the end-user has the correct version he should search all his hard disks for fldrview.ocx and fldrvw*.ocx and unregister ( using regsvr32.exe ) and remove all such instances. Then he should reinstall your program.


Licensing and registration

How can I enter license information in the FolderView ActiveX Control after I have purchased a license?

After you have purchased the FolderView ActiveX Control, you will receive a username and registration codes for the control. To register the control, follow these steps..

  • Right-click on the control in design-mode, i.e. when the control is on the form-designer and then select 'Activate License..'.
  • Enter the username and code exactly as you received it from LogicNP Software.

After the above steps are performed, there are still a few more steps that must be done before the control can use the registration information correctly and stop showing the About box. These steps are different for different development environments as described below :

  • Microsoft Visual Basic 6.0 : No additional steps are required
  • Microsoft Visual C++ 6.0 and Microsoft Visual C++.Net : Close and reopen the dialog resource on which the control is being used and change the position of the control ( and then hit undo if the position change is unwanted)
  • Microsoft Access 97/2000/XP : Delete and reinsert the control on the form(and give the reinserted control the original name, so that your code continues to work).
  • All other developing environments : Delete and reinsert the control on the form(and give the reinserted control the original name, so that your code continues to work).

Usage in web development

How can I use FolderView ActiveX Control on an HTML or ASP page?

Beginning with version 4.3 the developer must use the LPKTool to use the control on an HTML or ASP page as described below (Before running the LPKTool the control must already be properly licensed on the developer's machine) :

  • Run the LPKTool which you can download from http://msdn.microsoft.com/downloads/Default.aspx (Search for the term "lpk" on this web page).
  • Select "LogicNP Software FolderView ActiveX Control" from the list of the ActiveX Controls shown and then click on "Save and Exit" to save the license file. Specify control.lpk as the filename or you can specify your own filename.
  • In the HTML or ASP page that is using the control, add the following after the <BODY> start tag :

    <OBJECT CLASSID="clsid:5220CB21-C88D-11cf-B347-00AA00A28331">
    <PARAM NAME="LPKPath" VALUE="control.lpk">
    </OBJECT>


    The object tag shown above needs to precede any other object tags on your page. This tag loads the Microsoft license processor which manages licensed ActiveX controls on a web page.
  • Insert the ActiveX Control in the HTML or ASP page manually or using an HTML editor like Visual InterDev or Dreamweaver.

To have Internet Explorer automatically download the fldrvw70.ocx file on a target computer which doesn't have the file installed, you must package the fldrvw70.ocx file in a cab file and specify the cab file in the CODEBASE attribute of the FolderView object tag as shown below :

<OBJECT
classid=clsid:43805286-DDA2-11D3-B3E7-EDC559154043 codebase="FolderView.cab" height="300" id=FolderView1 style="LEFT: 0px; WIDTH: 405px; TOP: 0px; HEIGHT: 255px" ></OBJECT>

To make a CAB file for fldrvw70.ocx, you will need the Cabinet SDK (downloadable from http://download.microsoft.com/download/platformsdk/cab/2.0/w98nt42kmexp/en-us/Cabsdk.exe )

After you have installed the Cabinet SDK, run the cabarc.exe tool that comes with it as follows :

cabarc.exe n FolderView.cab fldrvw70.ocx

The above command line creates a new cabinet file named FolderView.cab and adds fldrvw70.ocx to it.


Customization ( custom icons, displaytexts, items, etc..)

How can I display my own icons and texts to files/folders shown in FolderView ActiveX Control?

You can display your own text or icons for files/folders shown in FolderView.

To change the text shown for a TreeNode, you should use the Text property. You can change this property for each node in the OnAfterNodeAdd event which is called after each node is added.

node1.Text = node1.DisplayName + "*"

To change the icons shown for a Treenode, you should use the IconIndex property. You can change this property for each node in the OnAfterNodeAdd event which is called after each node is added.

node1.IconIndex = 22

The above method allows you to display only those icons which are present in the system imagelist. If you want to display your own icons for nodes, then you should use the AddCustomIcon method. This method returns an index which you can then use with the IconIndex property.

Dim index as Integer
index= fldrvw.AddCustomIcon("c:\test.ico",Nothing)
node1.IconIndex = index


How can I change the font and colors used by FolderView ActiveX Control?

You can use the Font, BackColor and ForeColor properties to do so. You can change these properties at design time through the property-pages of the control.


How can I customize the underlying treeview control?

You should use the BorderStyle, HasButtons, HasLines, HasLinesAtRoot, HotTracking, Indent properties.


How can I set the root folder of FolderView ActiveX Control to something other than the 'Desktop'?

To set a root folder to something other than the Desktop, you should use the RootFolder or the RootPidl properties.

fldrvw.RootFolder="c:\"

The RootFolder property only accepts filesystem folders. To set a non-filesystem folder such as the 'Control Panel' as the root, you should use the RootPidl property.


How can I display overlay icons for non-shortcut or non-network folders/files?

You should use the OverlayIconIndex property of TreeNode.


How can I programmatically set a node as the root of the FolderView ActiveX Control?

You should use the SetAsRoot method of TreeNode.


How can I show checkboxes for each node in FolderView ActiveX Control?

You should set the ShowCheckBoxes property to True.


How can show/hide the check box for individual nodes?

You should set the ShowCheckBox property of TreeNode to True/False to show/hide the check box respectively.


How can I add custom contextmenu items in the contextmenu shown when a file/folder is right-clicked?

You should use the OnCustomContextMenuItemAdd event to add user-defined context menuitems. Then respond to the selection of the custom contextmenu item in the OnCustomContextMenuItemSelect event.


How can I add custom items in FolderView?

You should use the AddCustomNode to add custom items.



Behavior control ( e.g. prevent opening of files)

How can I automatically check/uncheck all children when a parent node is checked/unchecked?

Just set the AutoCheckChildren property to True.


How can I disable the default behavior of FolderView ActiveX Control to keystrokes like 'Del' and 'Ctrl-C', etc.?

Just set the DefaultKeyHandling property to False.


How can I prevent a node from being checked/unchecked?

You should set the Cancel parameter to True in the NodeChecked event.


How can I prevent a node from being expanded/collapsed?

You should set the Cancel parameter to True in the NodeExpanding and NodeCollapsing events respectively.


How can I prevent context menus from appearing when a folder/file is right-clicked?

You should set the ShowContextMenus property to False.


How can I show files in FolderView ActiveX Control?

You should set the ShowFiles property to True.


How can I prevent showing of contextmenu for certain items?

You should set the CancelEvent property to True in the NodeRightClick event.


How can I prevent certain shell commands (like Delete) from being executed on certain items?

You should set the Cancel parameter to True in the OnBeforeShellCommandExecute event.


How can I prevent the display of or change the default infotips shown for folders?

You should use the OnGetInfoTip event.


How can I prevent a dragdrop operation from starting on a per-item basis or prevent a drop action on a per-item basis or change the default drop action (e.g. from copy to move)?

You should use the OnOleStartDrag, OnOleDragDrop and OnOleDragOver events.



Filtering ( e.g. show only files)

How can I prevent non-filesystem folders/files or hidden folders/files from displaying?

You should set the ShowHiddenObjects and ShowSpecailFolders properties to False.

How can I prevent a certain node from displaying in FolderView ActiveX Control?

You should use the Delete method of TreeNode. A good place to call this method is in the OnAfterNodeAdd event.



General

How can I enumerate all the folders/files shown in FolderView ActiveX Control?

To enumerate through all the nodes, you should use the GetFirstItem and GetNextItem properties.

Dim x As FolderViewControl.TreeNode
Set x = FolderView1.GetFirstItem
While x Is Nothing = False
Debug.Print x.DisplayName
Set x = FolderView1.GetNextItem
Wend


How can I programmatically select a specific node in FolderView ActiveX Control?

You should use the SelectNode property.

fldrvw.SelectNode "c:\win98",0,True


How can I determine if a nodeis a custom node?

You should use the IsCustom property of TreeNode.


How can I determine if a node is the desktop node?

You should use the IsDesktop property of TreeNode.


How can I determine if a node is a file or a folder?

You should use the Attributes property of TreeNode.

if node1.Attributes(Folder) And Folder then msgbox "Folder" else msgbox "File"


How can I determine if a node belongs to the filesystem?

You should use the Attributes property of TreeNode.

If node1.Attributes(FileSystem) And FileSystem then msgbox "Folder" else msgbox "File"


How can I determine if a node is a shortcut?

You should use the Attributes property of TreeNode.

If node1.Attributes(Link) And Link then msgbox "Folder" else msgbox "File"


How can I determine if a node is readonly or hidden?

You should use the Attributes property of TreeNode.

If node1.Attributes(Hidden) And Hidden then msgbox "Folder" else msgbox "File"
if node1.Attributes(ReadOnly) And ReadOnly then msgbox "Folder" else msgbox "File"


How can I programmatically check/uncheck a node?

You should use the Checked property of TreeNode. To check a node, set this property to True, otherwise set it to False


How can I determine the check-state of a node?

You should use the CheckState property of TreeNode.


How can I get the child, parent or next or previous sibling node of a node?

You should use the Child, Parent, NextSibling and PreviousSibling properties respectively.


How can I show the 'Properties' dialog box for a folder/file?

You should use the ExecuteShellCommand method of TreeNode.

node1.ExecuteShellCommand cmdProperties


How can I open a folder/file in FolderView ActiveX Control?

You should use the ExecuteShellCommand method of TreeNode.

node1.ExecuteShellCommand cmdOpen


How can I execute commands like 'Cut', 'Copy', 'Paste', 'Delete', etc. for a folder/file?

You should use the ExecuteShellCommand method of TreeNode.

node1.ExecuteShellCommand cmdCut
node1.ExecuteShellCommand cmdCopy

node1.ExecuteShellCommand cmdPaste
node1.ExecuteShellCommand cmdDelete



How can programmatically expand or collapse a node?

You should use the Expanded property of TreeNode. To expand a node, set this property to True, to collapse a node, set this property to False.


How can I get the full path of a folder/file?

You should use the Path property of TreeNode.


How can I assign user-defined data for a node?

You should use the UserData property of TreeNode to store your data. This property can be set in the OnAfterNodeAdd event and freed ( if required ) in the OnBeforeNodeDelete event.


How can I use the FolderView ActiveX Controls with the FileView and ShComboBox ActiveX Controls?

All you need to do is write two simple lines of code!!

Sample applications demonstrating the use of the three controls together are included in this distribution package.

Fore more information, see Shell MegaPack.
For the latest information, product updates and special offers, please visit our website www.ssware.com

Using the three controls together

FolderView can be used with ShComboBox and FileView to create an entire Windows Explorer with custom functionality in your own application. Shown below is a simple application which uses the three controls together to give Windows Explorer functionality

Linking the three controls involves only two simple lines of code :

Consider a form or a dialog box where you have a FileView Control named fileVw, FolderView Control named fldrVw and a ShComboBox Control named shCmbBox.

Visual Basic

shCmbBox.FolderView = fldrvVw
fldrVw.FileView = fileVw

Visual C++

shCmbBox.SetFolderView((IDispatch*)fldrVw.GetControlUnknown()); fldrVw.SetFileView((IDispatch*)fileVw.GetControlUnknown());

Borland Delphi

shCmbBox.FolderView:=fldrvw.ControlInterface ;
fldrvw.FileView:=filevw.ControlInterface;

Borland C++ Builder

shCmbBox->FolderView = fldrVw->ControlInterface;
fldrVw->FileView = fileVw->ControlInterface;

Microsoft Access

shCmbBox.FolderView = fldrvVw.Object
fldrVw.FileView = fileVw.Object

Using FolderView with FileView only

Using FileView with FolderView requires just one line of code on your part. Just use the lower line of code shown.


Using FolderView with ShComboBox only

Using FileView with ShComboBox requires just one line of code on your part. The code required is given below.

Consider a form or a dialog box where you have a FileView Control named fileVw and a ShComboBox Control named shCmbBox.

Visual Basic

shCmbBox.FileView = fileVw

Visual C++

shCmbBox.SetFileView((IDispatch*)fileVw.GetControlUnknown());

Borland Delphi

shCmbBox.FileView:=filevw.ControlInterface ;

Borland C++ Builder

shCmbBox->FileView = fileVw->ControlInterface;

Microsoft Access

shCmbBox.FileView = fileVw.Object