\<bookmark_value\>programming examples for controls\</bookmark_value\>\<bookmark_value\>dialogs;loading (example)\</bookmark_value\>\<bookmark_value\>dialogs;displaying (example)\</bookmark_value\>\<bookmark_value\>controls;reading or editing properties (example)\</bookmark_value\>\<bookmark_value\>list boxes;removing entries from (example)\</bookmark_value\>\<bookmark_value\>list boxes;adding entries to (example)\</bookmark_value\>\<bookmark_value\>examples; programming controls\</bookmark_value\>\<bookmark_value\>dialog editor;programming examples for controls\</bookmark_value\>

Programming Examples for Controls in the Dialog Editor

The following examples are for a new dialog called "Dialog1". Use the tools on the Toolbox bar in the dialog editor to create the dialog and add the following controls: a Check Box called "CheckBox1", a Label Field called "Label1", a Button called "CommandButton1", and a List Box called "ListBox1".

Warning Icon

Be consistent with uppercase and lowercase letter when you attach a control to an object variable.

Global Function for Loading Dialogs

Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)

Dim oLib as Object

Dim oLibDialog as Object

Dim oRuntimeDialog as Object

    If IsMissing(oLibContainer) Then

        oLibContainer = DialogLibraries

    End If


    oLib = oLibContainer.GetByName(Libname)

    oLibDialog = oLib.GetByName(DialogName)

    oRuntimeDialog = CreateUnoDialog(oLibDialog)

    LoadDialog() = oRuntimeDialog

End Function

Displaying a Dialog

rem global definition of variables

Dim oDialog1 AS Object

Sub StartDialog1


    oDialog1 = LoadDialog("Standard", "Dialog1")


End Sub

Read or Edit Properties of Controls in the Program

Sub Sample1


    oDialog1 = LoadDialog("Standard", "Dialog1")

    REM get dialog model

    oDialog1Model = oDialog1.Model

    REM display text of Label1

    oLabel1 = oDialog1.GetControl("Label1")

    MsgBox oLabel1.Text

    REM set new text for control Label1

    oLabel1.Text = "New Files"

    REM display model properties for the control CheckBox1

    oCheckBox1Model = oDialog1Model.CheckBox1

    MsgBox oCheckBox1Model.Dbg_Properties

    REM set new state for CheckBox1 for model of control

    oCheckBox1Model.State = 1

    REM display model properties for control CommandButton1

    oCMD1Model = oDialog1Model.CommandButton1

    MsgBox oCMD1Model.Dbg_Properties

    REM display properties of control CommandButton1

    oCMD1 = oDialog1.GetControl("CommandButton1")

    MsgBox oCMD1.Dbg_Properties

    REM execute dialog


End Sub

Add an Entry to a ListBox

Sub AddEntry


    oDialog1 = LoadDialog("Standard", "Dialog1")

    REM adds a new entry to the ListBox

    oDialog1Model = oDialog1.Model

    oListBox = oDialog1.GetControl("ListBox1")

    Dim iCount as integer

    iCount = oListbox.ItemCount

    oListbox.additem("New Item" & iCount,0)

End Sub

Remove an Entry from a ListBox

Sub RemoveEntry


    oDialog1 = LoadDialog("Standard", "Dialog1")

    REM remove the first entry from the ListBox

    oDialog1Model = oDialog1.Model

    oListBox = oDialog1.GetControl("ListBox1")


End Sub