How to Obtain a Listing of Classes for OLE Client ControlID: Q87001
|
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.
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.
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
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
Sub FileType_Click ()
' When user selects a ClassDisplay, highlight the associated Class.
Identifier.ListIndex = FileType.ListIndex
End Sub
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