|
||||||
Creating and Customizing OpenOffice.org DialogsHow to Create a Dialog with the OpenOffice.org Basic IDEApplication dialogs tend very simple and uninspiring. However, that's not true of OpenOffice.org. An OpenOffice.org dialog is fully customizable and very flexible.
An underrated and underused area of OpenOffice.org is the dialog. Most visual programming languages (such as Visual Basic and VBScript) have some means of simple user interaction (for example MsgBox and InputBox), however the OpenOffice.org IDE (Integrated Design Environment) provides the means of creating a fully customizable dialog box which, in may ways, is better than OpenOffice.org Base's forms (as can been seen in figure 1 at the bottom of this article). In just a short time the programmer can create a very professional looking user interface. Creating a Blank OpenOffice.org DialogA custom dialog can be created very easily. It is just a matter of opening one of the OpenOffice.org applications (Writer, Calc or Base) and then clicking on:
The OpenOffice.org Basic Macro Organizer will now be displayed (as shown in figure 2). The programmer then needs to:
The application designer will now be able to see the blank dialog by clicking on the “Edit” button. If they do this then the IDE will display the blank dialog (as shown in figure 3). Adding Components to the OpenOffice.org DialogComponents can be added to the dialog from the IDE toolbox so that the programmer can add elements such as:
Once a component has been added then its properties can be accessed (by right mouse clicking on the object). The programmer can modify the properties to:
After a little dragging and dropping the developer will have produced a dialog that will improve the user interaction with their application. Loading and Running the DialogSome programming is required in order for the new dialog to be made visible to the user (and so anyone unsure of how to create an OpenOffice.org macro should read How to Create OpenOffice.org Database Macros). The macro itself requires a global object that will represent the dialog: Dim oLogon As Object
There are then two steps to displaying the dialog:
It's worth encapsulating the first step into a function (so that it can be reused for any dialog): Function loadDialog (dialog as String, Optional library as String)
Dim oLib as Object
Dim oDialog as Object
If isMissing(library) Then
library = "Standard" 'the default library for any document
End If
DialogLibraries.LoadLibrary(library)
oLib = DialogLibraries.GetByName(library)
oDialog = oLib.GetByName(dialog)
loadDialog = CreateUnoDialog(oDialog)
End Function
This function loads all of the correct libraries as well as the dialog itself. This next macro makes use of the function and executes the dialog: Sub Main
oLogon = LoadDialog ("logon")
oLogon.Execute
End Sub
If this macro is run then the custom dialog will be displayed. It will not have any functionality at the the moment and so the programmer will have to:
And at the end of the process the developer's application will contain a completely customized dialog – one that adds useful content for the application users.
The copyright of the article Creating and Customizing OpenOffice.org Dialogs in Computer Programming is owned by Mark Alexander Bain. Permission to republish Creating and Customizing OpenOffice.org Dialogs in print or online must be granted by the author in writing.
|
||||||
|
|
||||||
|
|
||||||