Home  | Source Code  | Tools  | Links  | Search  |  
¿Habla Español?
Source Code Sections
ASP.NET General Internet Windows Explorer Windows Forms Old VB6 Code
Info

Valid XHTML 1.0!

Valid CSS!

How to show the Property Pages of a control at run-time

The code uses the ISpecifyPropertyPages interface to enumerate the property pages supported by the control and then show them with a call to OleCreatePropertyFrame API.

Copy to clipboardShowProperties
Sub ShowProperties( _
   ByVal Ctrl As Object, _
   Optional ByVal CtrlName As String, _
   Optional ByVal hWndParent As Long)
Dim oSPP As ISpecifyPropertyPages
Dim tPages As CAUUID

   On Error Resume Next
   
   ' Get ISpecifyPropertyPages interface
   ' of the control
   Set oSPP = Ctrl
   
   If oSPP Is Nothing Then
   
      ' If the QI fails try using the
      ' Object property of the control
      Set oSPP = Ctrl.Object
      
      If oSPP Is Nothing Then
         
         ' Reset the error handler
         On Error GoTo 0
         
         ' Raise an error
         Err.Raise 13
         
      End If
      
   End If
   
   ' Get the CLSIDs of the pages
   oSPP.GetPages tPages
   
   ' Show the pages
   OleCreatePropertyFrame hWndParent, 0, 0, _
      CtrlName, 1, Ctrl, tPages.cElems, _
      ByVal tPages.pElems, 0, 0, 0

   ' Release the pages array
   CoTaskMemFree tPages.pElems
   
End