home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch27code / frmobj.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-30  |  6.2 KB  |  173 lines

  1. VERSION 4.00
  2. Begin VB.Form frmObject 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "OLE Demonstration"
  5.    ClientHeight    =   4260
  6.    ClientLeft      =   2670
  7.    ClientTop       =   3675
  8.    ClientWidth     =   6975
  9.    Height          =   4665
  10.    Icon            =   "frmobj.frx":0000
  11.    Left            =   2610
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4260
  14.    ScaleWidth      =   6975
  15.    Top             =   3330
  16.    Width           =   7095
  17.    Begin VB.CommandButton cmdClose 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "&Close"
  20.       Default         =   -1  'True
  21.       Height          =   375
  22.       Left            =   5085
  23.       TabIndex        =   1
  24.       Top             =   135
  25.       Width           =   1770
  26.    End
  27.    Begin VB.CommandButton cmdVerbs 
  28.       Caption         =   "Verbs"
  29.       Height          =   375
  30.       Index           =   0
  31.       Left            =   5085
  32.       TabIndex        =   2
  33.       Top             =   585
  34.       Width           =   1770
  35.    End
  36.    Begin VB.OLE oleVideo 
  37.       AutoVerbMenu    =   0   'False
  38.       Class           =   "MPlayer"
  39.       Height          =   4005
  40.       Left            =   135
  41.       TabIndex        =   6
  42.       TabStop         =   0   'False
  43.       Top             =   135
  44.       Visible         =   0   'False
  45.       Width           =   4830
  46.    End
  47.    Begin VB.OLE oleSound 
  48.       AutoActivate    =   0  'Manual
  49.       AutoVerbMenu    =   0   'False
  50.       BackStyle       =   0  'Transparent
  51.       BorderStyle     =   0  'None
  52.       Class           =   "SoundRec"
  53.       Height          =   3360
  54.       Left            =   135
  55.       OleObjectBlob   =   "frmobj.frx":000C
  56.       SourceDoc       =   "c:\win\chimes.wav"
  57.       TabIndex        =   5
  58.       TabStop         =   0   'False
  59.       Top             =   135
  60.       Visible         =   0   'False
  61.       Width           =   4470
  62.    End
  63.    Begin VB.OLE oleProject 
  64.       AutoActivate    =   0  'Manual
  65.       AutoVerbMenu    =   0   'False
  66.       BackStyle       =   0  'Transparent
  67.       Height          =   3360
  68.       Left            =   135
  69.       OleObjectBlob   =   "frmobj.frx":4E24
  70.       SizeMode        =   1  'Stretch
  71.       SourceDoc       =   "e:\proj\softdev.mpp"
  72.       TabIndex        =   4
  73.       TabStop         =   0   'False
  74.       Top             =   135
  75.       Visible         =   0   'False
  76.       Width           =   4470
  77.    End
  78.    Begin VB.OLE olePowerPoint 
  79.       AutoActivate    =   0  'Manual
  80.       AutoVerbMenu    =   0   'False
  81.       BackStyle       =   0  'Transparent
  82.       Class           =   "PowerPoint.Show.7"
  83.       Height          =   3360
  84.       Left            =   135
  85.       OleObjectBlob   =   "frmobj.frx":17E3C
  86.       SizeMode        =   3  'Zoom
  87.       SourceDoc       =   "e:\vb4\sample.ppt"
  88.       TabIndex        =   3
  89.       TabStop         =   0   'False
  90.       Top             =   135
  91.       Visible         =   0   'False
  92.       Width           =   4470
  93.    End
  94.    Begin VB.OLE olePaint 
  95.       Appearance      =   0  'Flat
  96.       AutoActivate    =   0  'Manual
  97.       AutoVerbMenu    =   0   'False
  98.       BackStyle       =   0  'Transparent
  99.       BorderStyle     =   0  'None
  100.       Class           =   "Paint.Picture"
  101.       Height          =   3360
  102.       Left            =   135
  103.       OleObjectBlob   =   "frmobj.frx":26A54
  104.       OLETypeAllowed  =   1  'Embedded
  105.       SizeMode        =   3  'Zoom
  106.       SourceDoc       =   "e:\nt\arches.bmp"
  107.       TabIndex        =   0
  108.       TabStop         =   0   'False
  109.       Top             =   135
  110.       Visible         =   0   'False
  111.       Width           =   4470
  112.    End
  113. Attribute VB_Name = "frmObject"
  114. Attribute VB_Creatable = False
  115. Attribute VB_Exposed = False
  116. '*********************************************************************
  117. ' FRMOBJECT.FRM: Used to display a object and its verbs.
  118. '*********************************************************************
  119. Option Explicit
  120. Private OLEObject As OLE
  121. '*********************************************************************
  122. ' Unload the dialog.
  123. '*********************************************************************
  124. Private Sub cmdClose_Click()
  125.     Unload Me
  126. End Sub
  127. '*********************************************************************
  128. ' Execute a verb (verbs are from 1 to x, so you need to add 1).
  129. '*********************************************************************
  130. Private Sub cmdVerbs_Click(Index As Integer)
  131.     On Error Resume Next
  132.     OLEObject.DoVerb (Index + 1)
  133.     If Err Then MsgBox "Err = " & Format(Err) & ": " & Error, vbCritical
  134. End Sub
  135. '*********************************************************************
  136. ' This public method is used to display the form and to call necessary
  137. ' loading routines.
  138. '*********************************************************************
  139. Public Sub Display(obj As OLE)
  140.     Set OLEObject = obj
  141.     OLEObject.Visible = True
  142.     PrepareForm
  143.     Show vbModal
  144. End Sub
  145. '*********************************************************************
  146. ' Center the form and load the command buttons for its verbs.
  147. '*********************************************************************
  148. Public Sub PrepareForm()
  149. Dim i As Integer
  150.     '*****************************************************************
  151.     ' Center the dialog.
  152.     '*****************************************************************
  153.     Move (Screen.Width - Width) / 2, _
  154.     (Screen.Height - Height) / 2
  155.     '*****************************************************************
  156.     ' Create and label a command button on the form for each verb.
  157.     '*****************************************************************
  158.     For i = 1 To OLEObject.ObjectVerbsCount - 1
  159.         '*************************************************************
  160.         ' cmdVerbs(0) already exists, so skip it.
  161.         '*************************************************************
  162.         If i > 1 Then Load cmdVerbs(i - 1)
  163.         With cmdVerbs(i - 1)
  164.             If i > 1 Then
  165.                 .Top = cmdVerbs(i - 2).Top _
  166.                      + cmdVerbs(i - 2).Height + 75
  167.             End If
  168.             .Caption = OLEObject.ObjectVerbs(i)
  169.             .Visible = True
  170.         End With
  171.     Next i
  172. End Sub
  173.