0
votes

I'm writing a vb6 user control (for my sins) and all has gone well up until now. I'm struggling to get the height and width of the parent/container.

The User-control is exported as an activeX control (.ocx), registered on the target machine using Regsvr32 and then embedded into an existing app.

I don't have access to the existing apps code so I can't inject anything that way.

I've tried accessing the UserControl.Parent object but receiving errors.

Does anyone know how to do this or can set me down the right path. My main language is c# so be kind to me please.

1
What kind of errors are you receiving?GSerg

1 Answers

0
votes

Most likely you are trying to fiddle with Parent before the control has been sited. Doing this instead works just fine:

Option Explicit

Public Sub Update()
    'Call from parent container's Resize event handler, etc.
    Cls
    With Parent
        Print .ScaleWidth; " × "; .ScaleHeight
        Print .Width; " × "; .Height
    End With
End Sub

Private Sub UserControl_Initialize()
    AutoRedraw = True 'We're using Print here.
End Sub

Private Sub UserControl_InitProperties()
    Update
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    Update
End Sub