Code Protection and Obfuscator For .Net, Licensing And Copy Protection for .Net, ActiveX and MFC

ShComboBox ActiveX Control How-To Guide

Categories

Search for a topic in the following categories..

Installation
Deployment and distribution
Licensing and registration
Usage in web development
General - programmatic control

*In this guide the terms folder, file, ComboBoxItem 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 ShComboBox 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 ShComboBox 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 ShComboBox ActiveX Control is automatically registered on your system, when you install it. If you need to register the control again, for example if it gets unregistered for some reason and it is not visible 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 shcmb70.ocx file on the regsvr32.exe file that is present in the Windows System directory.


Deployment and distribution

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

An application which uses ShComboBox ActiveX Control should distribute the file shcmb70.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 ShComboBox 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 ShComboBox v4.3 or earlier, because all these versions of ShComboBox had the same GUID and a filename of shcmbbox.ocx. The problem occurs because the different versions of ShComboBox 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 ShComboBox. In this case, the version of ShComboBox that comes with the other program will replace the one that your program uses.

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

Therefore, if your program uses ShComboBox 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 ShComboBox 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 shcmbbox.ocx and shcmb*.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 ShComboBox ActiveX Control after I have purchased a license?

After you have purchased the ShComboBox 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 ShComboBox 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 ShComboBox 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 shcmb70.ocx file on a target computer which doesn't have the file installed, you must package the shcmb70.ocx file in a cab file and specify the cab file in the CODEBASE attribute of the shcombobox object tag as shown below :

<OBJECT
classid=clsid:C13BB99A-FB40-47f4-A1C8-35679D1CB1E8 codebase="shcmbbox.cab" height="300" id=shCmbBox style="LEFT: 0px; WIDTH: 405px; TOP: 0px; HEIGHT: 255px" ></OBJECT>

To make a CAB file for shcmb70.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 shcmbbox.cab shcmb70.ocx

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


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

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

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

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 = fldrVw.Object
fldrVw.FileView = fileVw.Object

 

Using ShComboBox with FileView only

Using ShComboBox with FileView 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 ShComboBox Control named shCmbBox and a FileView Control named fileVw.

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

 

Using ShComboBox with FolderView only

Using ShComboBox with FolderView 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 ShComboBox Control named shCmbBox and FolderView Control named fldrVw.

Visual Basic

shCmbBox.FolderView = fldrVw

Visual C++

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

Borland Delphi

shCmbBox.FolderView:=fldrVw.ControlInterface ;

Borland C++ Builder

shCmbBox->FolderView= fldrVw->ControlInterface;

Microsoft Access

shCmbBox.FolderView = fldrVw.Object


How can I show only drives like that in the DriveListBox in Visual Basic?

You should set the ShowDrivesOnly property to True.


How can I enable automatic completion of paths like in Windows Explorer?

You should set the AutoComplete property to True.


How can I enumerate all the items displayed in ShComboBox ActiveX Control?

You should use the ItemsCount and ComboBoxItem properties.

Dim x As ComboBoxItem
For i = 0 To shcmbbox.ItemsCount - 1
Set x = shcmbbox.ComboBoxItem(i)
lstBox.AddItem x.DisplayName
Next i


How can I control the number of items that are shown when ShComboBox is dropped down?

You should set the DropDownLines property to the desired value.


How can I determine the number of items shown in ShComboBox ActiveX Control?

You should use the ItemCount property.


How can I retrieve the currently selected item in ShComboBox ActiveX Control?

You should use the SelectedItem property.


How can I select an item as the active item?

You should use the SelectItem method.

shcmbbox.SelectItem 2


How can I set a file/folder as the active item in ShComboBox ActiveX Control?

You should use the SetPath method.

shcmbbox.SetPath "c:\win98\system"

SetPath can only be used for filesystem folders. To set non-filesystem files/folders like Control Panel, you should use the SetPidl method.


How can I show files in ShComboBox ActiveX Control?

You should set the ShowFiles property to True.


How can I prevent special folders like Control Panel from showing in ShComboBox ActiveX Control?

You should set the ShowVirtualFolders property to False.


How can I show the full path for the selected item in ShComboBox ActiveX Control?

You should set the ShowFullPath property to True.