Hide

SftOptions 1.0 - ActiveX Options Control

Display
Print

Using SftOptions with Visual Basic

Adding The SftOptions Control To A Project
Adding The SftOptsIO Control To A Project

Adding The SftOptions Control To A Project

The SftOptions control implements the user interface to allow the end-user to customize all available application options.

The SftOptions control must be added to the Toolbox before it can be used in a project. The Toolbox normally displays the standard Visual Basic controls and any other ActiveX controls that have been added previously.

Visual Basic Project

The control is added to the Toolbox using the Project, Components... menu command, which displays the following dialog:

Components Dialog

Select the control "SftOptions 1.0 Options Control" by placing a check mark next to it and click OK. This adds the control to the Toolbox. If you don't see the control in the list, make sure Selected Items Only is not checked. Once you click Apply or OK and an error message is displayed, the product SftOptions is not correctly installed or the control may have been unregistered accidentally. Quit Visual Basic and use the entry Register Design Time Control in the SftOptions 1.0 program group to register the control. Restart Visual Basic and try to add the control to the Toolbox again.

This adds two controls to the Toolbox, the SftOptions user interface control and the SftOptsIO options I/O control.

  • SftOptions user interface control
  • SftOptsIO options I/O control

Now the SftOptions control can be added to a form by clicking on the SftOptions button of the Toolbox.

Adding The SftOptions Control

All required steps have now been completed to use SftOptions.

For a complete example, also add two button controls to the form, a Close button (named CloseButton) and an Apply button (named ApplyButton).

Adding Buttons

Add the following sample code to initialize the control:

Private Sub Form_Load()
    ApplyButton.Enabled = False
    With SftOptions1
        .Add "", "Main", "Your first sample", entrySftOptionsTopic, "", "", Nothing, "", "", "", ""
        .Add "Main", "Rb1", "Radio Button 1", entrySftOptionsRadioButton, "", "", Nothing, "", "", "", ""
        .Add "Main", "Rb2", "Radio Button 2", entrySftOptionsRadioButton, "", "", Nothing, "", "", "", ""
        .Add "Main", "Rb3", "Radio Button 3", entrySftOptionsRadioButton, "", "", Nothing, "", "", "", ""
        .Add "", "Cb1", "Check Box Option", entrySftOptionsCheckBox, "", "", Nothing, "", "", "", ""
        .IO.Registry = "USR:Software\Softelvdm\TestData\FirstSample"
        .Load
        .InitializationComplete
    End With
End Sub

Private Sub SftOptions1_ApplyStatusChange()
    ApplyButton.Enabled = SftOptions1.ApplyStatus
End Sub

Private Sub ApplyButton_Click()
    SftOptions1.Save
End Sub

Private Sub CloseButton_Click()
    Unload Me
End Sub

In this example, the control is initialized at run-time using code. Of course it is also possible (and much easier) to set up all option entries using the property pages. You can access the property pages by right-clicking on the control and select the Properties... entry of the popup menu.

You can run the sample application and it displays a simple Options dialog with a few entries. After modifying some of the entries, click the Apply Button. Using Regedit you can review the registry settings at HKEY_CURRENT_USER\Software\Softelvdm\TestData\FirstSample. For example, if you select the check box in this example, the registry key "Cb1" is set to the value "1".

Adding The SftOptsIO Control To A Project

The SftOptsIO control offers simplified Registry and INI file I/O to retrieve or set option values without a user interface.

The SftOptsIO control is added to the Toolbar in the same manner as the SftOptions control (see Adding The SftOptions Control To A Project).

The SftOptsIO control can be added to a form by clicking on the SftOptsIO button of the Toolbox. This control is only visible at design-time. At run-time it is not visible to the end-user. It can only be used by the application.

The SftOptsIO control must be initialized by setting its Registry property (this could of course also be done using the property pages):

SftOptsIO1.Registry = "USR:Software\Softelvdm\TestData\FirstSample"

Retrieving an option value using the same name as used by the SftOptions control is very easy:

Dim CheckBoxValue As String
CheckBoxValue = SftOptsIO1.OptionValue("Cb1")

In this example, the CheckBoxValue variable would contain "1" if the option is selected.

The SftOptions control has many properties and methods which you can use. This is a very simple example and doesn't even begin to exploit the capabilities of this control. Please take a moment to familiarize yourself with the objects offered by the SftOptions control. Each object represents a specific area of the control and can be fully customized. Also make sure to run the demo which is included with this product and take a look at the included samples.


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.