Search code examples
vb6activexincompatibilitypropertybag

Remove incompatible spaces from propertybag to solve error when saving form with ActiveX control


I am looking for a way to have VB6 edit a controls' propertybag right before or while the Form is being saved..

We're using an activeX control (AxisMediaControl) that seemingly uses Spaces in it's propertybag names which throws an error when trying to save the form the control is on.

System Error &H80070057 (-2147024809)

The same problem is described here: Source of a similar problem, but i don't have *.h files ()

but since we use the compiled ActiveX i can't edit the way it handles writing properties, and we don't have access to the source of the ActiveX..

I've managed to create a workaround loading the control at runtime,as an Array of objects, but this way i wont have them indexed to capture events by index.

Dim Axis(1) As AxisMediaControl
For i% = 0 To 1
   Set Axis(i%) = Controls.Add("AxisMediaControl.AxisMediaControl.1", "AMC" & i%)
   Axis(i%).Tag = "CAM" + Format$(i%)
Next i%
'   Play Video

    With Axis(0)
        .Top = 600
        .Left = 240
        .Width = 9135
        .Height = 5535
        .Visible = True

        .StretchToFit = True
        .MaintainAspectRatio = True
        .EnableContextMenu = True

        .MediaFile = VideoFile$
        .play
    End With


'   Play Stream

    With Axis(1)
        .Top = 6840
        .Left = 240
        .Width = 9135
        .Height = 5535
        .Visible = True

        .StretchToFit = True
        .MaintainAspectRatio = True
        .EnableContextMenu = True

        .MediaFile = VideoStream$
        .play
    End With

The ActiveX is working fine with younger versions of Visual Basic like express 2005 or vb.net and only occurs under vb6.

Are there ways to 'edit' the way the properties are saved to the propertybag?

Can i edit the dll or ocx to behave differently and have a working up-to-date version of an ActiveX that was previously incompatible? I've tried using Resource Hacker on the dll files but to no avail since my knowledge there is limited..


Solution

  • Since you mentioned the control works in dotnet versions of VB, a workaround could be to write a wrapper in VB.NET, and then use that wrapper from VB6. This wrapper would provide a standard "ActiveX" (COM) interface and internally just call the original control. You would only need to expose the bare minimum of functionality in the wrapper, just to minimize the effort involved.

    (Note - while this might work technically it may not be the best overall solution. For instance, if upgrading to a more modern control is possible that might be a better investment of time.)


    Edit 1: A wrapper would impose some additional overhead, that is certain. But this overhead might not be important at all. If you only have to make a few calls for instance the runtime effect is probably irrelevant. OTOH if you have to call this thing within the innermost loop of some algorithm (doubtful for a UI control but...) that could be more of a problem.

    Edit 2: If you don't already have any dotnet components in your app it might not be worth adding that dependency just for this issue. Or maybe it would be, if this truly is a showstopper; but that could be an additional consideration to think through carefully.