How to Obtain a Listing of Classes for OLE Client Control

Last reviewed: June 21, 1995
Article ID: Q87001
The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 2.0 - Microsoft Professional Toolkit for Microsoft Visual Basic programming

  system for Windows, version 1.0

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.

  • 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.

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

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

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

  • 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
    
    

  • 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
    
    

  • 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
    
    

  • 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 reference words: 1.00 2.00
    KBCategory: kbole kbprg kbcode
    KBSubcategory: IAPOLE


    THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

    Last reviewed: June 21, 1995
    © 1998 Microsoft Corporation. All rights reserved. Terms of Use.