例: ParentView property

  1. 次のスクリプトは文書の取得元の NotesView オブジェクト (view) のタイトルと ParentView プロパティが返す NotesView オブジェクト (parentView) のタイトルを表示します。view と parentView は .SOMEDOCS.NSF の同じビュー [Main View] を表すため、表示されるタイトルは同じです。
    Sub Initialize
      Dim db As New NotesDatabase( "", "somedocs.nsf" )
      Dim view As NotesView
      Dim parentView As NotesView
      Dim doc As NotesDocument
      Set view = db.GetView( "By Category" )
      If Not view Is Nothing Then
        Set doc = view.GetFirstDocument
        Set parentView = doc.ParentView
        Messagebox view.Name , , "view.Name"
        Messagebox parentView.Name , , "parentView.Name"
      End If
    End Sub
  2. 次のエージェントは、指定された Document オブジェクトの親ビューを表示する関数を実行します。
    Sub Initialize
      Dim db As New NotesDatabase( "", "" )
      Dim doc As NotesDocument
      Call db.open( "snapper", "progwork2.nsf" )
      
      Dim view As NotesView
      Set view = db.GetView( "By Category"  )
      If Not view Is Nothing Then
        Set doc = view.GetFirstDocument
        Call printViewName (doc, "first doc in view")
      End If
      
      Dim dc As NotesDocumentCollection
      Set dc = db.AllDocuments
      If dc.Count > 0 Then
        Set doc = dc.getFirstDocument
        Call printViewName (doc, "first doc in collection")
      End If
      
      Set doc = New notesdocument (db)
      Call printViewName (doc, "new doc")
      
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.document
      Call printViewName (doc, "ui doc")
    End Sub
    Sub printViewName (d As NotesDocument, t As String)
      Dim v As notesview
      Set v = d.ParentView
      If v Is Nothing Then
        Messagebox "Document did not come from a view.", , t
      Else
        Messagebox "Document came from the " + _
        v.Name + " view.", , t
      End If
    End Sub