21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Closing With the Close Button in the Title Bar<br />

Working With Dialogs<br />

You can close a dialog by clicking the close button on the title bar of the dialog window. The Execute method of<br />

the dialog returns the value 0, which is the same as when you click Cancel.<br />

Closing With an Explicit Program Call<br />

You can also close an open dialog window with the endExecute method:<br />

Dlg.endExecute()<br />

The Execute method of the dialog returns the value 0, which is the same as when you click Cancel.<br />

Access to Individual Control Elements<br />

A dialog can contain any number of control elements. You can access these elements through the getControl<br />

method that returns the control element by name.<br />

Dim Ctl As Object<br />

Ctl = Dlg.getControl("MyButton")<br />

Ctl.Label = "New Label"<br />

This code determines the object for the MyButton control element and then initializes the Ctl object variable<br />

with a reference to the element. Finally the code sets the Label property of the control element to the New<br />

Label value.<br />

Note – Unlike <strong>OpenOffice</strong>.<strong>org</strong> Basic identifiers, the names of control elements are case sensitive.<br />

Working With the Model of Dialogs and Control<br />

Elements<br />

The division between visible program elements (View) and the data or documents behind them (Model) occurs<br />

at many places in <strong>OpenOffice</strong>.<strong>org</strong> API. In addition to the methods and properties of control elements, both<br />

dialog and control element objects have a subordinate Model object. This object allows you to directly access the<br />

content of a dialog or control element.<br />

In dialogs, the distinction between data and depiction is not always as clear as in other API areas of<br />

<strong>OpenOffice</strong>.<strong>org</strong>. Elements of the API are available through both the View and the Model.<br />

The Model property provides program-controlled access to the model of dialog and control element objects.<br />

Dim cmdNext As Object<br />

cmdNext = Dlg.getControl("cmdNext")<br />

cmdNext.Model.Enabled = False<br />

This example deactivates the cmdNext button in the Dlg dialog with the aid of the model object from cmdNext.<br />

Properties<br />

Name and Title<br />

Every control element has its own name that can be queried using the following model property:<br />

Chapter 11 · Dialogs 153

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!