Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Control's property pages at runtime???

I am currently implementing an ActiveX control with Measurement Studio for Visual Basic.
Everything is going fine, but I have one general problem which I cannot solve. The control should show the own property pages at runtime mode. Whit one OLE control, developed under visual c++ or ATL this is strength forward. But I have no idea how to do this from Visual Basic. I spend a lot of time to search in internet but unfortunately there is no information at all.
Please HELP!
Thanks in advance!
Nikolai
0 Kudos
Message 1 of 9
(11,400 Views)
You can do this with the ISpecifyPropertyPages COM interface and the OleCreatePropertyFrame function. The hard part is getting definitions of the interface, interface methods, supporting data types, etc. that you can use from VB. Here's one way to do it:


  • Download tl_ole.zip, which is a type library that contains definitions for several OLE interfaces, structures, and functions.

  • Create a new VB project and add a reference to the type library.

  • Add a Measurem
    ent Studio ActiveX control (i.e., CWGraph) to the form and add a button to the form.

  • Add the following code to your VB project:

    Private Sub Command1_Click()
    ShowPropertyPages CWGraph1.Object, "Graph", Me.hWnd
    End Sub

    Public Sub ShowPropertyPages(comObject As Object, name As String, hWnd As Long)
    Dim specifyPages As ISpecifyPropertyPages

    Set specifyPages = comObject
    If Not specifyPages Is Nothing Then
    Dim pages As CAUUID
    specifyPages.GetPages pages

    OleCreatePropertyFrame hWnd, 0, 0, name, 1, comObject, pages.cElems, ByVal pages.pElems, 0, 0, 0
    CoTaskMemFree pages.pElems
    End If
    End Sub



Note that you pass in the Object property of the control, not the control reference itself. When you run this code, this will bring up the property pages of the controls at run-time. If you make any changes in the property pages and click OK, the changes will be reflected in the control.

Hop
e this helps.

- Elton
Message 2 of 9
(11,403 Views)
Tanks Elton,
It works like a gun �.

Is it possible to show the property pages of my own control from VB or I should have to use the same trick to make my own type library that contains definitions of the OLE interfaces for the control and to access them in this complicated manner from the control itself?


Regards,
Nikolai
0 Kudos
Message 3 of 9
(11,401 Views)
It may be, but I do not know of an easy way to do this. The ActiveX container usually handles this. VB hides a lot of the details of creating ActiveX controls and I do not see an easy way to programmatically launch the property pages from UserControl or PropertyPage.

- Elton
0 Kudos
Message 4 of 9
(11,401 Views)
Anyway it is exactly what I wanted, and like I said, works perfect!
Thank you again!
The olelib.tlb just add only about 200 kb overhead to the CAB file and I can live with that.
Nikolai
0 Kudos
Message 5 of 9
(11,401 Views)
You actually don't have to deploy the type library. The type library just contains definitions that are usable from VB for Win32 functions and COM interfaces that are already on the system. The type library doesn't actually contain any executable code. VB will compile the definitions that you use into your exe/dll/ocx, so you should be able to take the type library out and not install it on the client machine and your application will work the same.

- Elton
0 Kudos
Message 6 of 9
(11,401 Views)
I simply used the package and deployment wizard add-in, so never thought about this, but you�re right, it�s just interface definitions. Anyway, i am going to go in a bit different way with the distribution of the control because of the explorer security against the activeX controls make my nervous. I am going to integrate all things in msi installer and deploy the control with url based installation:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/a_url_based_windows_installer_installation_example.asp

Take Care,
Nikolai
0 Kudos
Message 7 of 9
(11,401 Views)
Dear Elton
II am trying to follow yor suggestions, but I am unable to download  tl_ole.zip.
Giorgio
0 Kudos
Message 8 of 9
(10,979 Views)
Hi Giorgio,

Try downloading it from here:

http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip

Have a good one!

Dan Weiland
Applications Engineer
National Instruments
Dan Weiland
0 Kudos
Message 9 of 9
(10,963 Views)