Advanced PowerBuilder

HomePrevious Lesson: Insert Class in the OLE Control
Next Lesson: Inserting an Object in the OLE Control

Inserting an Existing File in the OLE Control

Calling the InsertFile() embeds a copy of the existing object into the control. The following example inserts the specified object.

String lFileNameWithFullPath, lFileName
Integer lResult
lResult = GetFileOpenName( "Select File to Open " + &
"in OLE Control", lFileNameWithFullPath,lFileName)

If lResult = 0 Then Return

lResult = ole_1.InsertFile( lFileNameWithFullPath )

If lResult <> 0 Then
MessageBox( "File Insert Error", lResult )
Return -1000
End If

ole_1.Activate( InPlace! )

Activate() function activates the inserted file, i.e., invokes the OLE Server (The program that created the file).

To see it in the action, run the application. Select "Module/OLE 2.0 Control Examples" option from the menu. Click on the "Insert File" CommandButton.
HomePrevious Lesson: Insert Class in the OLE Control
Next Lesson: Inserting an Object in the OLE Control