⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 derived.cls

📁 此源码为vb圣经编码
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Derived"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'***************************************************************
' (c) Copyright 2000 Matthew J. Curland
'
' This file is from the CD-ROM accompanying the book:
' Advanced Visual Basic 6: Power Techniques for Everyday Programs
'   Author: Matthew Curland
'   Published by: Addison-Wesley, July 2000
'   ISBN: 0-201-70712-8
'   http://www.PowerVB.com
'***************************************************************
Option Explicit

Implements IDelayCreation

'Type for stack alloc
Private Type InitData
    AggData(0) As AggregateData
    IIDs(0) As VBGUID
End Type

Private m_Hook As UnknownHook
Private m_BaseOverride As BaseOverride
Private m_Base As Base

Private Sub Class_Initialize()
Dim InitData As InitData
Dim LastIID As LastIID
    
    'Get the IID for the base class.
    InitLastIID LastIID
    On Error Resume Next
    Set m_Base = LastIID.QIThis
    On Error GoTo 0
    Set m_Base = New Base
    
    m_Base.SetOuter Me
    With InitData
        With .AggData(0)
            .Flags = adUseIIDs Or adNoDelegator Or _
              adDelayDontCacheResolved Or adFullyResolved
            .FirstIID = 0
            Set .pObject = Me
        End With
        .IIDs(0) = LastIID.IID
        VBoost.AggregateUnknown Me, .AggData, .IIDs, m_Hook
    End With
End Sub

Private Function IDelayCreation_Create(IID As VBoostTypes.VBGUID) As stdole.IUnknown
    'We only specified 1 IID, so we don't
    'have to check if we got the right one.
    'If there is more than one override, then
    'store the IID's at module level.
    With m_BaseOverride
        If .BD.cRefs Then
            VBoost.AssignAddRef IDelayCreation_Create, VarPtr(.BD)
        Else
            Set IDelayCreation_Create = VBoost.CreateDelegator(Me, m_Base, , VarPtr(.BD), AddressOf modDerived.DestructBaseOverride)
            Set .Derived = Me
            modDerived.HookVTable .BD.pVTable
        End If
    End With
End Function

Friend Function Base_OverrideMe() As String
    Base_OverrideMe = m_Base.OverrideMe & _
      " overridden by Derived"
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -