OpenDoc method
The document associated with the specified index in the document list of the active folder of the specified Content Manager OnDemand OLE Control is opened and displayed in the window of this control.
- Method:
- short OpenDoc(
- Parameters
- Index
- Specifies the zero-based index of a document within the document list of the active folder.
- pPath
- Points to a null-terminated character string containing the fully-qualified path of a file containing the document data. If this parameter is NULL, the document data is retrieved from the Content Manager OnDemand database; if not NULL, the data is taken from the specified file, but a resource group is retrieved from the database if required.
- ControlId
- Specifies the control id of a Content Manager OnDemand OLE Control. If the value is zero, the control ID of this control is used.
- Description
- The document associated with the specified index in the document list of the active folder of
the specified Content Manager OnDemand OLE Control is opened and
displayed in the window of this control.
The reference to a different Content Manager OnDemand OLE Control allows several windows to simultaneously display documents from a single document list. This avoids the overhead of multiple logon, open folder, and search folder operations. If only one Content Manager OnDemand OLE Control is being used within an application, the ControlId should always be set to zero.
The document retrieval can be cancelled by using the CancelOperation method. If a cancel facility is made available to the user, it is desirable to call the OpenDoc method on a background thread and allow the user interface thread to monitor the cancellation signal.
- Return Value
- Refer to return codes.
- See Also
- GetNumFolderDisplayFields, GetFolderDisplayFieldNames, GetNumDocsInList, GetDocDisplayValues, CloseDoc, CancelOperation, WasOperationCancelled, and ShowWaitCursorDuringCancelableOperation methods
C/C + +
The following example creates a list box of the folder document list names and associated values and opens the document selected by a user. CArsOle * pArsCtrl;
ArsOleName * pNames;
ArsOleValue * pValues;
CListBox * pDocList;
char * pLine;
short rc, k, opr, num_fields;
long j, num_docs;
int size;
VARIANT vari;
.
.
// During dialog initialization:
rc = pArsCtrl->GetNumFolderDisplayFields( &vari );
if ( rc != ARS_OLE_RC_SUCCESS )
ERROR;
num_fields = var.iVal;
pNames = new ArsOleName[ max( num_fields, 1 ) ];
rc = pArsCtrl->GetFolderDisplayFieldNames( (IUnknown*)pNames, num_fields );
if ( rc != ARS_OLE_RC_SUCCESS )
ERROR;
rc = pArsCtrl->GetNumDocsInList( &vari );
if ( rc != ARS_OLE_RC_SUCCESS )
ERROR;
num_docs = var.lVal;
.
.
.
.
pValues = new ArsOleValue[ max( num_fields, 1 ) ];
size = num_fields * ( sizeof(ArsOleName) + sizeof(ArsOleValue) + 5 );
pLine = new char[ size ];
for ( j = 0, pLine[0] = '\0'; j < num_docs; j++ )
{
rc = pArsCtrl->GetDocDisplayValues( j, pValues, num_fields );
if ( rc != ARS_OLE_RC_SUCCESS )
ERROR;
for ( k = 0; k < num_fields; k++ )
{
strcat( pLine, pNames[k] );
strcat( pLine, " = " );
strcat( pLine, pValues[k] );
if ( k < num_fields - 1 )
strcat( pLine, ", " );
}
pDocList->InsertString( -1, pLine );
}
pDocList->SetCurSel( 0 );
.
.
// During OK button processing:
rc = pArsCtrl->OpenDoc( (long)pDocList->GetCurSel( ) , NULL, 0 );
if ( rc != ARS_OLE_RC_SUCCESS )
ERROR;
.
.
Visual Basic
Dim rc, count, i, j As Integer
Dim num_fields, num_docs As Variant
Dim Names() As String
Dim Line As String
Dim Temp As String
.
.
rc = ArsOle.GetNumFolderDisplayFields(num_fields)
If rc <> ARS_OLE_RC_SUCCESS Then
MsgBox "ERROR"
End
End If
ReDim Names(num_fields -1)
For count = 0 To num_fields -1
rc = ArsOle.GetFolderDisplayFieldName(count, Temp)
Names(count) = Temp
Next count
rc = ArsOle.GetNumDocsInList(num_docs)
If rc <> ARS_OLE_RC_SUCCESS Then
MsgBox "ERROR"
End
End If
For j = 0 To num_docs -1
For i = 0 To num_fields -1
rc = ArsOle.GetDocDisplayValue(j, i, Temp)
Line = Line + Names(i) + " = " + Temp
If i < num_fields Then
Line = Line + ", "
End If
Next i
lbDocs.AddItem Line
Next j
.
.
'During OK button processing:
rc = ArsOle.OpenDoc (lbDocs.List(lbDocs.ListIndex), "", 0)
If rc <> ARS_OLE_RC_SUCCESS Then
MsgBox "ERROR"
End
End If