How to Obtain a Listing of Classes for OLE Client Control

ID: Q87001


The information in this article applies to:


SUMMARY

Below is an example of how to obtain a list of the Object Linking and Embedding (OLE) class properties for the OLE Client control in Visual Basic. This example is based on the ServerAcceptFormats example on page 214 in the "Microsoft Professional Toolkit for Visual Basic: Custom Control Reference" for version 1.0.

This example gets the information from the REG.DAT file in your Windows directory. It uses the ServerClasses property to return a listing of the classes to a list box. The Class property is discussed on pages 198-201 and 207 of the "Microsoft Professional Toolkit for Visual Basic: Custom Control Reference" for version 1.0. The ServerClasses property is discussed on pages 201 and 217 in the same manual.

Note that the CtlName property in Visual Basic version 1.0 has been changed to the Name property in Visual Basic version 2.0.


MORE INFORMATION

This example uses a single form with two list boxes, two labels, and one OLE Client control. One list box should have a CtlName (or Name) of Identifier, and the other list box should have a CtlName (or Name) of FileType. Each label is placed above a list box, with the captions of Identifier and File Type, respectively.

There are three event procedures (Form_Load, Identifier_Click, and FileType) and one procedure, located in the general section of Form1, called Fillitems(S$).

The example results in two lists. The available OLE classes are listed in the Identifier list box, and the Class File Types are listed in the File Type list box.

When you click a certain class in the Identifier list box, the associated class display is highlighted in the second Identifier-Display list box.

Step-by-Step Example

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.


  2. From the File menu, choose Add File. In the Files box, select the OLECLIENT.VBX custom control file. The OLE Client tool will appear in the Toolbox.


  3. Add two label boxes (Label1 and Label2) and two list boxes (List1 and List2) to Form1. Position Label1 above List1, and Label2 above List2.


  4. Change the Control Name of List1 to Identifier, and change the Caption of Label1 to Identifier.


  5. Change the Control Name of List2 to FileType, and change the Caption of Label2 to FileType.


  6. Add the following code to the Form_Load event procedure:
    
       Sub Form_Load ()
          Dim I As Integer
          ' Fill the Identifier and FileType list boxes
          For I = 0 To OLEClient1.ServerClassCount - 1
             Identifier.AddItem OLEClient1.ServerClasses(I)
             FileType.AddItem OLEClient1.ServerClassesDisplay(I)
          Next I
       End Sub
     


  7. Add the following code to the Identifier_Click event procedure after you have changed the control name in step 4 above:
    
       Sub Identifier_Click ()
          ' When user selects a Class, highlight the associated ClassDisplay.
          FileType.ListIndex = Identifier.ListIndex
          ' Display information associated with the selected class.
          FillItems (OLEClient1.ServerClasses(Identifier.ListIndex))
       End Sub
     


  8. Add the following code to the FileType_Click event procedure after you have changed the control name in step 4:
    
       Sub FileType_Click ()
          ' When user selects a ClassDisplay, highlight the associated Class.
          Identifier.ListIndex = FileType.ListIndex
       End Sub
     


  9. Add the following code to the (general) section of the form's Code window under Object:
    
       Sub FillItems (S$)
          Dim I As Integer
          ' Set the ServerClass.
          OLEClient1.ServerClass = S$
       End Sub
     


Additional query words: 1.00 2.00


Keywords          : 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: June 22, 1999