Using the Chooser

It is strongly recommended that you use the DriverHelper.Chooser object for selecting the driver for the device to be used by your application. It is extremely simple to use, and presents the user with a consistent interface for device selection and configuration. When you connect to a standard driver, you use the ProgID, for example "NexStar.Telescope" in a CreateObject() call.

The chooser returns the selected device's ProgID. You can pass a (saved) ProgID to the Choose() method, and that device will be pre-selected in the list. The drivers are listed in a special registry area, with the user-friendly name and progID. The Chooser hides all of this from you, and allows us to evolve the registry area without fear of breaking your code. Also, the Chooser provides an interlock which forces the user to pop open the configuration dialog for the chosen device before being able to click OK to change the selected device. It looks like this to the user:

The code to use the Chooser is simple (set a reference to ASCOM Scope Driver helper objects for early binding and IntelliSense):

  Dim chsr as New ASCOM.Utilities.Chooser
  ' This will be a Telescope chooser
  chsr.DeviceType = "Telescope"  
  ' Retrieve the ProgID of the previously chosen
  ' device, or set it to ""
  scopeProgID = chsr.Choose(scopeProgID)
  ' Maybe save the new telescope choice ProgID here...
  ' Create the Telescope and connect it.
  Set scope = CreateObject(scopeProgID)
  scope.Connected = True
  ... etc.
FYI, the Chooser can be configured to choose any ASCOM device type. The default is "Telescope", but you can change the Chooser.DeviceType property to something else (e.g. "Focuser") and the Chooser will then work for that device type.