Showing a Dialog

From Apache OpenOffice Wiki
Jump to: navigation, search



After a dialog has been designed using the dialog editor, a developer wants to show the dialog from within the program code. The necessary steps are shown in the following example:

 Sub ShowDialog()
     Dim oLibContainer As Object, oLib As Object
     Dim oInputStreamProvider As Object
     Dim oDialog As Object
     Const sLibName = "Library1"
     Const sDialogName = "Dialog1"
     REM library container
     oLibContainer = DialogLibraries
     REM load the library
     oLibContainer.loadLibrary( sLibName )
     REM get library
     oLib = oLibContainer.getByName( sLibName )
     REM get input stream provider
     oInputStreamProvider = oLib.getByName( sDialogName )
     REM create dialog control
     oDialog = CreateUnoDialog( oInputStreamProvider )
     REM show the dialog
     oDialog.execute()
 End Sub

The dialog control is created by calling the runtime function CreateUnoDialog() which takes an object as parameter that supports the com.sun.star.io.XInputStreamProvider interface. This object provides an input stream that represents an XML description of the dialog. The section Advanced Library Organization explains the accessing to the object inside the library hierarchy. The dialog control is shown by calling the execute() method of the com.sun.star.awt.XDialog interface. It can be closed by calling endExecute(), or by offering a Cancel or OK Button on the dialog. For additional information, see Programming Dialogs and Dialog Controls.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages