VERSION 5.00
Begin VB.Form frmExtension 
   Caption         =   "Form1"
   ClientHeight    =   2850
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5070
   LinkTopic       =   "Form1"
   ScaleHeight     =   2850
   ScaleWidth      =   5070
   StartUpPosition =   3  'Windows の既定値
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   375
      Left            =   3720
      TabIndex        =   12
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Frame frmExecute 
      Caption         =   "Execute"
      Height          =   1095
      Left            =   120
      TabIndex        =   6
      Top             =   1200
      Width           =   4815
      Begin VB.TextBox txtMode 
         BeginProperty DataFormat 
            Type            =   1
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1041
            SubFormatType   =   1
         EndProperty
         Height          =   270
         Left            =   1080
         TabIndex        =   9
         Text            =   "txtMode"
         Top             =   360
         Width           =   2415
      End
      Begin VB.TextBox txtResult 
         Height          =   270
         Left            =   1080
         TabIndex        =   8
         Text            =   "txtResult"
         Top             =   720
         Width           =   2415
      End
      Begin VB.CommandButton cmdExecute 
         Caption         =   "&Execute"
         Height          =   375
         Left            =   3600
         TabIndex        =   7
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label lblMode 
         Caption         =   "Mode :"
         Height          =   255
         Left            =   120
         TabIndex        =   11
         Top             =   360
         Width           =   615
      End
      Begin VB.Label lblResult 
         Caption         =   "Result :"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   720
         Width           =   615
      End
   End
   Begin VB.Frame Freme1 
      Caption         =   "Extension"
      Height          =   975
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4815
      Begin VB.CommandButton cmdAdd 
         Caption         =   "&Add"
         Height          =   375
         Left            =   3600
         TabIndex        =   5
         Top             =   480
         Width           =   1095
      End
      Begin VB.TextBox txtParam 
         Height          =   270
         Left            =   1080
         TabIndex        =   4
         Text            =   "txtParam"
         Top             =   600
         Width           =   2415
      End
      Begin VB.TextBox txtName 
         Height          =   270
         Left            =   1080
         TabIndex        =   2
         Text            =   "txtName"
         Top             =   240
         Width           =   2415
      End
      Begin VB.Label lblParam 
         Caption         =   "Parameter :"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   600
         Width           =   975
      End
      Begin VB.Label lblName 
         Caption         =   "Name :"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   240
         Width           =   615
      End
   End
End
Attribute VB_Name = "frmExtension"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private caoEng As CaoEngine
Private caoCtrl As CaoController
Private caoExt As CaoExtension

Private Sub Form_Load()
    Set caoEng = New CaoEngine
    Set caoCtrl = caoEng.Workspaces(0).AddController("RC1", "CaoProv.Dummy")

    txtName = ""
    txtParam = ""
    txtMode = ""
    txtResult = ""
    
    cmdExecute.Enabled = False
    
    cmdRelease

End Sub

Private Sub Form_Unload(Cancel As Integer)
    ' CAOオブジェクトの解放
    cmdRelease
    
    Set caoCtrl = Nothing
    Set caoEng = Nothing

End Sub

Private Sub cmdAdd_Click()
    cmdRelease

    Set caoExt = caoCtrl.AddExtension(txtName.Text, txtParam.Text)
    cmdExecute.Enabled = True

End Sub

Private Sub cmdExecute_Click()
    Dim varResult As Variant
    
    varResult = caoExt.Execute(Val(txtMode))
    
    If varResult = 0 Then
        txtResult = "(EMPTY)"
    Else
        txtResult = varResult
    End If
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdRelease()
    If Not caoExt Is Nothing Then
        caoCtrl.Extensions.Remove caoExt.Index
        Set caoExt = Nothing
    End If
    
    cmdExecute.Enabled = False
End Sub


