OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Working With Dialogs<br />
size.<br />
The example shows a dialog that contains a label and a list box.<br />
A dialog containing a label and a list box<br />
You can open a dialog with the following code:<br />
Dim Dlg As Object<br />
DialogLibraries.LoadLibrary("Standard")<br />
Dlg = CreateUnoDialog(DialogLibraries.Standard.DlgDef)<br />
Dlg.Execute()<br />
Dlg.dispose()<br />
CreateUnoDialog creates an object called Dlg that references the associated dialog. Before you can create the<br />
dialog, you must ensure that the library it uses (in this example, the Standard library) is loaded. The<br />
LoadLibrary method performs this task.<br />
Once the Dlg dialog object has been initialized, you can use the Execute method to display the dialog. Dialogs<br />
such as this one are described as modal because they do not permit any other program action until they are closed.<br />
While this dialog is open, the program remains in the Execute call.<br />
The dispose method at the end of the code releases the resources used by the dialog once the program ends.<br />
Closing Dialogs<br />
Closing With OK or Cancel<br />
If a dialog contains an OK or a Cancel button, the dialog is automatically closed when you click one of these<br />
buttons. More information about working with these buttons is discussed in Dialog Control Elements in Detail.<br />
If you close a dialog by clicking the OK button, the Execute method returns a return value of 1, otherwise a<br />
value of 0 is returned.<br />
Dim Dlg As Object<br />
DialogLibraries.LoadLibrary("Standard")<br />
Dlg = CreateUnoDialog(DialogLibraries.Standard.MyDialog)<br />
Select Case Dlg.Execute()<br />
Case 1<br />
MsgBox "Ok pressed"<br />
Case 0<br />
MsgBox "Cancel pressed"<br />
End Select<br />
152 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010