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

📄 firstcontrol.ctl

📁 VB圣经
💻 CTL
字号:
VERSION 5.00
Begin VB.UserControl FirstControl 
   ClientHeight    =   3600
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   5835
   ScaleHeight     =   3600
   ScaleWidth      =   5835
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "This is an unregistered control"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   18
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   435
      Left            =   90
      TabIndex        =   0
      Top             =   150
      Width           =   5070
      WordWrap        =   -1  'True
   End
   Begin VB.Menu mnuLoadSecond 
      Caption         =   "Load Second Control"
      NegotiatePosition=   2  'Middle
   End
End
Attribute VB_Name = "FirstControl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'***************************************************************
' (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
Private Const strCLSID_APPCONTEXT As String = "{325FBD60-35EC-11D4-91FE-D41203C10000}"

Private Sub mnuLoadSecond_Click()
Dim AppContext As Object
Dim pOleObject As IOleObject
Dim pOleControlSite As IOleControlSite
Dim Extender As VBControlExtender
    Set AppContext = CoGetClassObject(CLSIDFromString(strCLSID_APPCONTEXT), CLSCTX_INPROC_SERVER Or CLSCTX_LOCAL_SERVER, 0, IIDFromString(strIID_IDispatch))
    Set pOleObject = AppContext.ShowNewForm(App.Path & "\" & App.EXEName & ".ocx", "SecondControl")
    'Demonstrate interaction with the parent form. Note that the return value
    'can also be assigned directly to a SecondControl type variable.
    Set pOleControlSite = pOleObject.GetClientSite
    Set Extender = pOleControlSite.GetExtendedControl
    Extender.Parent.Caption = "Custom Loaded Control"
End Sub

Private Sub UserControl_Resize()
    Label1.Width = ScaleWidth
End Sub

⌨️ 快捷键说明

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