| Home | Previous Lesson: Opening a Sub-Storage Next Lesson: Inserting an Existing File In the OLE Control |
This function creates a new object of the specified class and embeds in the control. After inserting the class, if you activate the OLE server, it will activate appropriate OLE server depending on the class you specified in this function. The following example inserts a word document class and also opens another file. After inserting the class, when you open any file that belongs to the specified class in the OLE control, you will see OLE control empty, even though it opened successfully. By calling InsertClass function, the OLE class is set to the specified class and subsequent OLE server activation invokes the right server (MS Word in this example). You might ask, where can I find these classes. You can find them in the Registration database.
String lFileNameWithFullPath, lFileName
Integer lResult
lResult = GetFileOpenName( "Select Document to " + &
"Open in OLE Control", lFileNameWithFullPath, &
lFileName, "Doc", "Documents (*.doc), *.doc" )
If lResult <> 1 Then Return
lResult = ole_1.InsertClass( "word.document" )
If lResult <> 0 Then
MessageBox( "Error while inserting Class", &
"Error No: " + String( lResult ) )
Return -1000
End If
lResult = ole_1.Open( lFileNameWithFullPath )
If lResult <> 0 Then
MessageBox( "Error while opening the specified" + &
"Class File", "Error No: " + String( lResult ))
Return -1000
End If
To see it in the action, run the application. Select 'Module > OLE Control Examples' menu option. Click on the Insert Class CommandButton.
| Home | Previous Lesson: Opening a Sub-Storage Next Lesson: Inserting an Existing File In the OLE Control |