【问题标题】:VB6 - User control/ActiveX control - how to get parent dimensionsVB6 - 用户控件/ActiveX 控件 - 如何获取父维度
【发布时间】:2023-03-20 13:31:01
【问题描述】:

我正在编写一个 vb6 用户控件(为我的罪过),到目前为止一切顺利。我正在努力获取父/容器的高度和宽度。

用户控件导出为 activeX 控件 (.ocx),使用 Regsvr32 在目标机器上注册,然后嵌入到现有应用程序中。

我无权访问现有的应用程序代码,因此无法以这种方式注入任何内容。

我尝试访问 UserControl.Parent 对象但收到错误。

有谁知道如何做到这一点,或者可以让我走上正确的道路。我的主要语言是 c#,所以请善待我。

【问题讨论】:

  • 您收到什么样的错误?

标签: vb6


【解决方案1】:

您很可能在控件被定位之前试图摆弄 Parent。这样做效果很好:

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

【讨论】:

    猜你喜欢
    • 2013-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-08
    • 1970-01-01
    相关资源
    最近更新 更多