Indhold

# Tjenesten SFDialogs. Dialog

The Dialog service contributes to the management of dialogs created with the Basic Dialog Editor or dialogs created on-the-fly. Each instance of the current class represents a single dialog box displayed to the user.

Et dialogfelt kan vises i modal eller ikke-modal tilstand.

I modal tilstand vises feltet og udførelsen af makro-processen er udsat, indtil der trykkes på en af knapperne OK eller Annuller. I mellemtiden kan brugerhandlinger, udført på feltet, udløse bestemte handlinger.

I ikke-modal tilstand "Flyder" dialogfeltet på brugerskrivebordet og udførelsen af makroprocessen fortsætter normalt. En ikke-modal dialog lukker, når den afsluttes med metoden Terminate() eller når sessionen LibreOffice Slutter. Knappen Luk vindue er inaktiv i ikke-modale dialoger.

Et dialogfelt forsvinger fra hukommelsen efter dets udtrykkelige afslfutning.

Tjenesten SFDialogs.Dialog er nært beslægtet med tjenesten SFDialogs.DialogControl.

## Kald og brug af tjeneste

Før brug af tjenesten Dialog skal biblioteket ScriptForge være indlæst eller importeret:

• Basic-makroer kræver, at biblioteket ScriptForge indlæses med følgende udtryk:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
• Python-scripts kræver import af scriptforge-modulet:
from scriptforge import CreateScriptService

The Dialog service is invoked through the CreateScriptService method. It requires three supplemental positional arguments to specify the dialog box to activate:

Container: "GlobalScope" til forudinstallerede biblioteker eller et vinduesnavn som defineret af tjenesten ScriptForge.UI. Standardværdien tom streng "" står for det aktuelle dokument.

Bibliotek: Biblioteksnavn med skelnen mellem Store og små bogstaver, der findes i containeren. Standardværdien er "Standard".

DialogNavn: En streng, hvor der skelnes mellem Store og små bogstaver, og som betegner dialogen.

The examples below in Basic and Python display the dlgConsole dialog that belongs to the ScriptForge shared library:

          Dim oDlg As Object, lButton As Long
          Dim Container As String, Library As String, DialogName As String
          Set oDlg = CreateScriptService("SFDialogs.Dialog", "GlobalScope", "ScriptForge", "dlgConsole")
          '... initialisering af kontrolelementer skrives her...
          lButton = oDlg.Execute()
          'Standard tilstand = Modal
          If lButton = oDlg.OKBUTTON Then
          '... Proceskontrollerer og gør, hvad der er nødvendigt her
          End If
          oDlg.Terminate()

Eller med Python:

        dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole')
        # ... initialisering af kontroller skrives her...
        rc = dlg.Execute()
        # Standard-tilstand er Modal
        if rc == dlg.OKBUTTON:
            # ... Behandl kontroller og gør, hvad der er nødvendigt her
        dlg.Terminate()

Use the string "GlobalScope" as the container argument when the dialog is stored either in My Macros & Dialogs or in Application Macros & Dialogs.

The dialog service offers methods that create new controls dynamically in an existing dialog predefined with the Dialog Editor. A dialog is initialized with controls in the Dialog Editor and new controls can be added at run-time before or after the dialog Execute() statement.

The Dialog service can equally be invoked - through the CreateScriptService method - when creating dialogs on-the-fly. It requires two supplemental positional arguments after the name of the ad-hoc service "NewDialog":

DialogName: A case-sensitive string designating the dialog.

Place: Window location of the dialog being either :

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

        Sub newDialog()
            Dim oDlg As Object
           oDlg = CreateScriptService("NewDialog", "myDialog1", Array(100,200, 40, 110))
           ' ...
        End Sub

Or using Python:

        def newDialog():
           dlg = CreateScriptService('NewDialog', 'myDialog1', (100,200, 40, 110))
           # ... Process controls and do what is needed

All properties and methods applicable to predefined dialogs are available for such new dialogs. In particular the series of CreateXXX() methods for the addition of new dialog controls.

## Retrieving the Dialog instance that triggered a dialog event

An instance of the Dialog service can be retrieved via the SFDialogs.DialogEvent service, provided that the dialog was initiated with the Dialog service. In the example below, oDlg contains the Dialog instance that triggered the dialog event.

        Sub aDialogEventHander(ByRef poEvent As Object)
            Dim oDlg As Object
            Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent)
            ' ...
        End Sub

Or using Python:

        def control_event_handler(event: uno):
            dlg = CreateScriptService("SFDialogs.DialogEvent", event)
            # ...

Note that in the previous examples, the prefix "SFDialogs." may be omitted when deemed appropriate.

### Handling exceptions in event handlers

When creating an event handler for dialog events it is good practice to handle errors inside the subroutine itself. For instance, suppose the event handler below is called when the mouse button is pressed in the dialog window.

        Sub OnMouseButtonPressed(ByRef oEvent As Object)
        On Local Error GoTo Catch
            Dim oDialog As Object
            oDialog = CreateScriptService("DialogEvent", oEvent)
            ' Process the event
            Exit Sub
        Catch:
            MsgBox SF_Exception.Description
            SF_Exception.Clear
        End Sub

Call SF_Exception.Clear if you do not want the error to propagate after the dialog execution ended.

In Python use native try/except blocks for exception handling as shown below:

        def on_mouse_button_pressed(event=None):
            try:
                dlg = CreateScriptService("DialogEvent", event)
                # Process the event
            except Exception as e:
                # The object "bas" is an instance of the Basic service
                bas.MsgBox(str(e))

## Egenskaber

Navn | Skrivebeskyttet | Type | Beskrivelse
--- | --- | --- | ---
OKBUTTON | Ja | Integer | Værdi = 1. Der blev trykket på en OK-knap.
CANCELBUTTON | Ja | Integer | Værdi = 1. Der blev trykket på en OK-knap.
Caption | Nej | String | Angiv dialogens titel.
Height | Nej | Long | Angiv højden på dialogfeltet.
Modal | Ja | Boolean | Angiver, om dialogfeltet aktuelt er i udførelse i modal tilstand.
Name | Ja | String | Dialogens navn
Page | Nej | Integer | En dialog kan have flere sider, som brugeren kan gå igennem trin for trin. Dialogobjektets sideegenskab definerer, hvilken af dialogens sider, der er aktiv.
Visible | Nej | Boolean | Angiv, om dialogfeltet er synligt på skrivebordet. Som standard er det ikke synligt, før metoden Execute() køres og synligt derefter.
XDialogModel | Ja | UNO object | Det UNO-objekt, der repræsenter dialogenmodellen. Se detaljeret information i XControlModel og UnoControlDialogModel i APIens (Application Programming Interface) dokumentation.
XDialogView | Ja | UNO object | Det UNO-objekt, der repræsenter dialogvisningen. Se detaljeret information i XControl og UnoControlDialog i APIens (Application Programming Interface) dokumentation.
Width | Nej | Long | Angiv dialogfeltets bredde.

## Hændelsesegenskaber

On… properties return a URI string with the reference to the script triggered by the event. On… properties can be set programmatically.
Read its specification in the scripting framework URI specification.

Navn | Read/Write | Beskrivelse af Basic IDE
--- | --- | ---
OnFocusGained | Ja | Når fokus modtages
OnFocusLost | Ja | Når fokus mistes
OnKeyPressed | Ja | Tast trykket
OnKeyReleased | Ja | Tast sluppet
OnMouseDragged | Ja | Mus flyttet mens tast trykkes
OnMouseEntered | Ja | Mus indenfor
OnMouseExited | Ja | Mus udenfor
OnMouseMoved | Ja | Mus flyttet
OnMousePressed | Ja | Museknap trykket
OnMouseReleased | Ja | Museknap sluttet

Assigning events via the Basic IDE and assigning events via macros are mutually exclusive.

List of Methods in the Dialog Service
Activate Center Controls CloneControl CreateButton CreateCheckBox CreateComboBox CreateCurrencyField CreateDateField CreateFileControl CreateFixedLine | CreateFixedText CreateFormattedField CreateGroupBox CreateHyperlink CreateImageControl CreateListBox CreateNumericField CreatePatternField CreateProgressBar CreateRadioButton CreateScrollBar | CreateTableControl CreateTextField CreateTimeField CreateTreeControl EndExecute Execute GetTextsFromL10N Resize OrderTabs SetPageManager Terminate

Dimensioning a dialog is done by using Map AppFont units. A dialog or control model also uses AppFont units. While their views use pixels.

## Activate

Sæt fokus på den aktuelle forekomst af Dialog. Returner True, hvis fokuseringen lykkedes.

Den metode kaldes fra en dialog, en kontrolhændelse eller når der vises en dialog i ikke-modal tilstand.

### Syntaks:

svc.Activate(): bool

### Eksempel:

          Dim oDlg As Object
          Set oDlg = CreateScriptService(,, "myDialog")
          oDlg.Execute()
          ' ...
          oDlg.Activate()

Både Python- og LibreOffice-Basic-eksempler antager, at dialogen er gemt i det aktuelle dokuments Standard-bibliotek.

         dlg = CreateScriptService(,,'myDialog')
         dlg.Execute()
         # ...
         dlg.Activate()

## Center

Centrerer den aktuelle forekomst af dialogen midt på det ordnede vindue. Uden argumenter centrerer metoden dialogen i midten af det aktuelle vindue.

Returnerer True (Sand), når den lykkes.

### Syntaks:

svc.Center(opt Parent: obj): bool

### Parametre:

Overordnet: Et valgfrit objekt kan være enten…

- et ScriptForge-dialogobjekt

- et ScriptForge-dokument (Calc, Base, ...)-objekt

### Eksempel:

##### I Basic

         Sub TriggerEvent(oEvent As Object)
             Dim oDialog1 As Object, oDialog2 As Object, lExec As Long
             Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' Dialogen, der udløste hændelsen
             Set oDialog2 = CreateScriptService("Dialog", ...) ' Åbn en anden dialog
             oDialog2.Center(oDialog1)
             lExec = oDialog2.Execute()
             Select Case lExec
                 ...
         End Sub

##### I Python

         def triggerEvent(event: uno):
           dlg1 = CreateScriptService('DialogEvent.Dialog', event)  # Dialogen, der har udløst hændelsen
           dlg2 = CreateScriptService('Dialog', ...)  # Åbn en anden dialog
           dlg2.Center(dlg1)
           rc = dlg2.Execute()
           if rc is False:
             # ...

## CloneControl

Lav en kopi af et eksisterende kontrolelement af en hvilken som helst type i selve dialogen. Det kopierede kontrolelement efterlade uændret og kan flyttes.

### Syntaks:

svc.CloneControl(SourceName: str, ControlName: str, Left: num, Top: num): svc

### Parametre:

SourceName: Navnet på det kontrolelement, som skal kopieres.

ControlName: A valid control name as a case-sensitive string. It must not exist yet.

Left, Top: The coordinates of the new control expressed in Map AppFont units.

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

          Set myButton2 = oDlg.CloneControl("Button1", "Button2", 30, 30)

##### I Python

         dlg = dlg.CloneControl('Button1', 'Button2', 30, 30)

## Controls

Returner enten:

- listen over kontrolelementer, der er indeholdt i dialogen

- en DialogControl-klasseforekomst baseret på dens navn

### Syntaks:

svc.Controls(): str[0..*]

svc.Controls(controlname: str): svc

### Parametre:

KontrolNavn: Et gyldigt kontrolnavn som en streng, der skelner mellem Store og små bogstaver. Hvis den mangler, returneres listen over kontrolnavne som en nul-baseret matrix.

### Eksempel:

          Dim myDialog As Object, myList As Variant, myControl As Object
          Set myDialog = CreateScriptService("SFDialogs.Dialog", , "Standard", "Dialog1")
          myList = myDialog.Controls()
          Set myControl = myDialog.Controls("myTextBox")

         dlg = CreateScriptService('SFDialogs.Dialog','', 'Standard', 'Dialog1')
         ctrls = dlg.Controls()
         ctrl = dlg.Controls('myTextBox')

## CreateButton

Creates a new control of type Button in the current dialog.

### Syntaks:

svc.CreateButton(ControlName: str, Place: any, Toggle: bool = False, Push: str = ""): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Toggle: when True a Toggle button is created. Default = False

Push: "OK", "CANCEL" or "" (default)

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myButton = oDlg.CreateButton("Button1", Array(20, 20, 60, 15))

##### I Python

         myButton = dlg.CreateButton('Button1', (20, 20, 60, 15))

## CreateCheckBox

Creates a new control of type CheckBox in the current dialog.

### Syntaks:

svc.CreateCheckBox(ControlName: str, Place: any, Multiline: bool = False): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

MultiLine: When True (default = False), the caption may be displayed on more than one line.

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myCheckBox = oDlg.CreateCheckBox("CheckBox1", Array(20, 20, 60, 15), MultiLine := True)

##### I Python

         myCheckBox = dlg.CreateCheckBox('CheckBox1', (20, 20, 60, 15), MultiLine = True)

## CreateComboBox

Creates a new control of type ComboBox in the current dialog.

### Syntaks:

svc.CreateComboBox(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = True, LineCount: num = 5): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

DropDown: When True (default), a drop down button is displayed

LineCount: Specifies the maximum line count displayed in the drop down (default = 5)

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myComboBox = oDlg.CreateComboBox("ComboBox1", Array(20, 20, 60, 15), Dropdown := True)

##### I Python

         myComboBox = dlg.CreateComboBox('ComboBox1', (20, 20, 60, 15), Dropdown = True)

## CreateCurrencyField

Creates a new control of type CurrencyField in the current dialog.

### Syntaks:

svc.CreateCurrencyField(ControlName: str, Place: any, Border ="3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = +1000000, Increment: num = 1, Accuracy: num = 2): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

Increment: the step when the spin button is pressed. Default = 1

Accuracy: specifies the decimal accuracy. Default = 2 decimal digits

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myCurrencyField = oDlg.CreateCurrencyField("CurrencyField1", Array(20, 20, 60, 15), SpinButton := True)

##### I Python

         myCurrencyField = dlg.CreateCurrencyField('CurrencyField1', (20, 20, 60, 15), SpinButton = True)

## CreateDateField

Creates a new control of type DateField in the current dialog.

### Syntaks:

svc.CreateDateField(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = False, opt MinDate: datetime, opt MaxDate: datetime): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

DropDown: when True (default = False), a dropdown button is shown

MinDate: the smallest date that can be entered in the control. Default = 1900-01-01

MaxDate: the largest date that can be entered in the control. Default = 2200-12-31

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myDateField = oDlg.CreateDateField("DateField1", Array(20, 20, 60, 15), Dropdown := True)

##### I Python

         myDateField = dlg.CreateDateField('DateField1', (20, 20, 60, 15), Dropdown = True)

## CreateFileControl

Creates a new control of type FileControl in the current dialog.

### Syntaks:

svc.CreateFileControl(ControlName: str, Place: any, Border: str = "3D"): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myFileControl = oDlg.CreateFileControl("FileControl1", Array(20, 20, 60, 15))

##### I Python

         myFileControl = dlg.CreateFileControl('FileControl1', (20, 20, 60, 15))

## CreateFixedLine

Creates a new control of type FixedLine in the current dialog.

### Syntaks:

svc.CreateFixedLine(ControlName: str, Place: any, Orientation: str): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Orientation: for horizontal orientation use "H" or "Horizontal"; for vertical orientation use "V" or "Vertical".

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myFixedLine = oDlg.CreateFixedLine("FixedLine1", Array(20, 20, 60, 15), Orientation := "vertical")

##### I Python

         myFixedLine = dlg.CreateFixedLine('FixedLine1', (20, 20, 60, 15), Orientation = 'vertical')

## CreateFixedText

Creates a new control of type FixedText in the current dialog.

### Syntaks:

svc.CreateFixedText(ControlName: str, Place: any, Border: str = "3D", MultiLine: bool = False, Align: str = "LEFT", VerticalAlign: str = "TOP"): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "NONE" (default), "FLAT" or "3D"

Multiline: When True (default = False), the caption may be displayed on more than one line

Align: horizontal alignment, "LEFT" (default), "CENTER" or "RIGHT"

VerticalAlign: vertical alignment, "TOP" (default), "MIDDLE" or "BOTTOM"

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myFixedText = oDlg.CreateFixedText("FixedText1", Array(20, 20, 60, 15), MultiLine := True)

##### I Python

         myFixedText = dlg.CreateFixedText('FixedText1', (20, 20, 60, 15), MultiLine = True)

## CreateFormattedField

Creates a new control of type FormattedField in the current dialog.

### Syntaks:

svc.CreateFormattedField(ControlName: str, Place: any, Border: str = "3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = +1000000): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myFormattedField = oDlg.CreateFormattedField("FormattedField1", Array(20, 20, 60, 15), SpinButton := True)

##### I Python

         myFormattedField = dlg.CreateFormattedField('FormattedField1', (20, 20, 60, 15), SpinButton = True)

## CreateGroupBox

Creates a new control of type GroupBox in the current dialog.

### Syntaks:

svc.CreateGroupBox(ControlName: str, Place: any): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myGroupBox = oDlg.CreateGroupBox("GroupBox1", Array(20, 20, 60, 15))

##### I Python

         myGroupBox = dlg.CreateGroupBox('GroupBox1', (20, 20, 60, 15))

## CreateHyperlink

Creates a new control of type Hyperlink in the current dialog.

### Syntaks:

svc.CreateHyperlink(ControlName: str, Place: any, Border: str = "NONE", MultiLine: bool = False, Align: str = "LEFT", VerticalAlign: str = "TOP"): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "NONE" (default), "FLAT" or "3D"

MultiLine: When True (default = False), the caption may be displayed on more than one line

Align: horizontal alignment, "LEFT" (default), "CENTER" or "RIGHT"

VerticalAlign: vertical alignment, "TOP" (default), "MIDDLE" or "BOTTOM"

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myHyperlink = oDlg.CreateHyperlink("Hyperlink1", Array(20, 20, 60, 15), MultiLine := True)

##### I Python

         myHyperlink = dlg.CreateHyperlink('Hyperlink1', (20, 20, 60, 15), MultiLine = True)

## CreateImageControl

Creates a new control of type ImageControl in the current dialog.

### Syntaks:

svc.CreateImageControl(ControlName: str, Place: any, Border: str = "3D", Scale: str = "FITTOSIZE"): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

Scale: One of next values: "FITTOSIZE" (default), "KEEPRATIO" or "NO"

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myImageControl = oDlg.CreateImageControl("ImageControl1", Array(20, 20, 60, 15))

##### I Python

           myImageControl = dlg.CreateImageControl('ImageControl1", (20, 20, 60, 15))

## CreateListBox

Creates a new control of type ListBox in the current dialog.

### Syntaks:

svc.CreateListBox(ControlName: str, Place: any, Border: str = "3D", DropDown: bool = True, LineCount: num = 5, MultiSelect: bool = False): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

DropDown: When True (default), a drop down button is displayed

LineCount: Specifies the maximum line count displayed in the drop down (default = 5)

MultiSelect: When True, more than 1 entry may be selected. Default = False

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myListBox = oDlg.CreateListBox("ListBox1", Array(20, 20, 60, 15), Dropdown := True, MultiSelect := True)

##### I Python

         myListBox = dlg.CreateListBox('ListBox1', (20, 20, 60, 15), Dropdown = True, MultiSelect = True)

## CreateNumericField

Creates a new control of type NumericField in the current dialog.

### Syntaks:

svc.CreateNumericField(ControlName: str, Place: any, Border: str = "3D", SpinButton: bool = False, MinValue: num = -1000000, MaxValue: num = 1000000, Increment: num = 1, Accuracy: num = 2): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

SpinButton: when True (default = False), a spin button is present

MinValue: the smallest value that can be entered in the control. Default = -1000000

MaxValue: the largest value that can be entered in the control. Default = +1000000

Increment: the step when the spin button is pressed. Default = 1

Accuracy: specifies the decimal accuracy. Default = 2 decimal digits

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myNumericField = oDlg.CreateNumericField("NumericField1", Array(20, 20, 60, 15), SpinButton := True)

##### I Python

         myNumericField = dlg.CreateNumericField('NumericField1', (20, 20, 60, 15), SpinButton = True)

## CreatePatternField

Creates a new control of type PatternField in the current dialog.

### Syntaks:

svc.CreatePatternField(ControlName: str, Place: any, Border: str = "3D", EditMask: str, opt LiteralMax: str): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

EditMask: a character code that determines what the user may enter
Refer to Pattern_Field in the wiki for more information.

LiteralMask: contains the initial values that are displayed in the pattern field

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myPatternField = oDlg.CreatePatternField("PatternField1", Array(20, 20, 60, 15), EditMask := "NNLNNLLLLL", LiteralMask := "__.__.2002")

##### I Python

         myPatternField = dlg.CreatePatternField('PatternField1', (20, 20, 60, 15), EditMask = 'NNLNNLLLLL', LiteralMask = '__.__.2002')

## CreateProgressBar

Creates a new control of type ProgressBar in the current dialog.

### Syntaks:

svc.CreateProgressBar(ControlName: str, opt Place: any, Border: str = "3D", MinValue: num = 0, MaxValue: num = 100): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

MinValue: the smallest value that can be entered in the control. Default = 0

MaxValue: the largest value that can be entered in the control. Default = 100

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myProgressBar = oDlg.CreateProgressBar("ProgressBar1", Array(20, 20, 60, 15), MaxValue := 1000)

##### I Python

         myProgressBar = dlg.CreateProgressBar('ProgressBar1', (20, 20, 60, 15), MaxValue = 1000)

## CreateRadioButton

Creates a new control of type RadioButton in the current dialog.

### Syntaks:

svc.CreateRadioButton(ControlName: str, Place: any, MultiLine: bool = False): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

MultiLine: When True (default = False), the caption may be displayed on more than one line

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myRadioButton = oDlg.CreateRadioButton("RadioButton1", Array(20, 20, 60, 15), MultiLine := True)

##### I Python

         myRadioButton = dlg.CreateRadioButton('RadioButton1', (20, 20, 60, 15), MultiLine = True)

## CreateScrollBar

Creates a new control of type ScrollBar in the current dialog.

### Syntaks:

svc.CreateScrollBar(ControlName: str, Place, Orientation: str, Border: str = "3D", MinValue: num = 0, MaxValue: num = 100): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Orientation: for horizontal orientation use "H" or "Horizontal"; for vertical orientation use "V" or "Vertical".

Border: "3D" (default), "FLAT" or "NONE"

MinValue: the smallest value that can be entered in the control. Default = 0

MaxValue: the largest value that can be entered in the control. Default = 100

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myScrollBar = oDlg.CreateScrollBar("ScrollBar1", Array(20, 20, 60, 15), MaxValue := 1000)

##### I Python

         myScrollBar = dialog.CreateScrollBar('ScrollBar1', (20, 20, 60, 15), MaxValue = 1000)

## CreateTableControl

Creates a new control of type TableControl in the current dialog.

### Syntaks:

svc.CreateTableControl(ControlName: str, Place: any, Border: str = "3D", RowHeaders: bool = True, ColumnHeaders: bool = True, ScrollBars: str = "N", GridLines: bool = False): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

RowHeaders: when True (default), the row Headers are shown

ColumnHeaders: when True (default), the column Headers are shown

ScrollBars: possible values are: "H" or "Horizontal" (horizontal scrollbars), "V" or "Vertical" (vertical scrollbars); "B" or "Both" (both scrollbars); "N" or "None" (default) for no scrollbars. Scrollbars appear dynamically when they are needed.

GridLines: when True (default = False) horizontal and vertical lines are painted between the grid cells

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myTableControl = oDlg.CreateTableControl("TableControl1", Array(20, 20, 60, 15), ScrollBars := "B")

##### I Python

         myTableControl = dlg.CreateTableControl('TableControl1', (20, 20, 60, 15), ScrollBars = 'B')

## CreateTextField

Creates a new control of type TextField in the current dialog.

### Syntaks:

svc.CreateTextField(ControlName: str, Place: any, Border: str = "3D", MultiLine: bool = False, MaximumLength: num = 0, PasswordCharacter: str = ""): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

MultiLine: When True (default = False), the caption may be displayed on more than one line

MaximumLength: the maximum character count (default = 0 meaning unlimited)

PasswordCharacter: a single character specifying the echo for a password text field (default = "")

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

    Set myTextField = oDlg.CreateTextField("TextField1", Array(20, 20, 120, 50), MultiLine := True)

##### I Python

         myTextField = dlg.CreateTextField('TextField1', (20, 20, 120, 50), MultiLine = True)

## CreateTimeField

Creates a new control of type TimeField in the current dialog.

### Syntaks:

svc.CreateTimeField(ControlName: str, Place: any, Border: str = "3D", MinTime: num = 0, MaxTime: num = 24): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

MinTime: the smallest time that can be entered in the control. Default = 0

MaxTime: the largest time that can be entered in the control. Default = 24h

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myTimeField = oDlg.CreateTimeField("TimeField1", Array(20, 20, 60, 15))

##### I Python

         myTimeField = dlog.CreateTimeField('TimeField1', (20, 20, 60, 15))

## CreateTreeControl

Creates a new control of type TreeControl in the current dialog.

### Syntaks:

svc.CreateTreeControl(ControlName: str, Place: any, Border = "3D"): svc

### Parametre:

ControlName: the name of the new control. It must not exist yet.

Place: either …

- a Basic Array or Python tuple with 4 elements: (X, Y, width, height)

- a com.sun.star.awt.Rectangle [X, Y, Width, Height] object

All elements are expressed in Map AppFont units.

Border: "3D" (default), "FLAT" or "NONE"

### Returværdi:

An instance of SFDialogs.DialogControl service or Nothing.

### Eksempel:

##### I Basic

         Set myTreeControl = oDlg.CreateTreeControl("TreeControl1", Array(20, 20, 60, 15))

##### I Python

         myTreeControl = dlg.CreateTreeControl('TreeControl1', (20, 20, 60, 15))

## EndExecute

Afslutter visningen af en modal dialog og giver argumentet tilbage som den aktuelle Execute() løbende handlings returværdi.

EndExecute() opbevares sædvanligvis i behandlingen af en makro, der udløstes af en dialog eller en kontrolhændelse.

### Syntaks:

svc.EndExecute(returnvalue: int)

### Parametre:

returværdi: Den værdi, der videregives til den kørende Execute()-metode.

### Eksempel:

##### I Basic

          Sub OnEvent(poEvent As com.sun.star.lang.EventObject)
              Dim oDlg As Object
              Set oDlg = CreateScriptService("SFDialogs.DialogEvent", poEvent)
              oDlg.EndExecute(ReturnValue := 25)
          End Sub

##### I Python

         from com.sun.star.lang import EventObject
         def on_event(event: EventObject):
             dlg = CreateScriptService("SFDialogs.DialogEvent", event)
             dlg.EndExecute(25)

Ovennævnte omtaler af com.sun.star.lang.EventObject er valgfrie. Disse anmærkninger hjælper med at identificere LibreOffice Application Programming Interface (API).

## Execute

Viser dialogfeltet og venter, når modal, på den afslutning af brugeren. Den returnerede værdi er enten:

- 0: et tryk på knappen Annullér

- 1 : et tryk på knappen OK

- Ellers stoppede dialogen med et EndExecute()-udtryk, udsendt af en dialog eller en kontrolhændelse

Ved ikke-modale dialogfelter returnerer metoden altid 0 og udførelsen af makroen fortsætter.

### Syntaks:

svc.Execute(modal: bool = True): int

### Parametre:

modal: False (falsk) ved en ikke-modal dialog. Standard = True (sand).

### Eksempel:

I dette Basic-eksempel er dialogen myDialog gemt i det aktuelle dokuments Standard-bibliotek.

          Dim oDlg As Object, lReturn As Long
          Set oDlg = CreateScriptService("SFDialogs.Dialog", , , "myDialog")
          lReturn = oDlg.Execute(Modal := False)
          Select Case lReturn
              ' ...
          End Select

Denne Python-kode viser den modale dialog DlgConvert i det delte Basic-bibliotek DlgConvert.

         dlg = CreateScriptService("SFDialogs.Dialog", 'GlobalScope', 'Euro', "DlgConvert")
         rc = dlg.Execute()
         if rc == dlg.CANCELBUTTON:
             # ...

## GetTextsFromL10N

Erstatter alle faste tekststrenge i en dialog med deres oversatte versioner baseret på en forekomst af tjenesten L10N . Denne metode oversætter følgende strenge:

- Dialogens titel.

- Overskrift til følgende kontroltyper: Knap, Afkrydsningsfelt, Fast_linje, Fast_tekst, Gruppefelt og Alternativknap.

- Statiske strenge i Listefelter og Kombinationsfelter.

- Det værktøjstip eller den hjælpetekst, der vises, når musen svæver over kontrolfeltet.

Metoden returnerer True (sand), hvis den lykkes.

For at oprette en liste over strenge, der kan oversættes i en dialog, bruger du metoden AddTextsFromDialog fra tjenesten L10N.

### Syntaks:

svc.GetTextsFromL10N(l10n: svc): bool

### Parametre:

l10n: En forekomst af tjenesten L10N, som de oversatte strenge hentes fra.

### Eksempel:

Det følgende eksempel indlæser oversatte strenge og anvender dem på dialogen "Min dialog".

##### I Basic

         oDlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog")
         myPO = CreateScriptService("L10N", "/home/user/po_files/")
         oDlg.GetTextsFromL10N(myPO)
         oDlg.Execute()

##### I Python

         dlg = CreateScriptService("Dialog", "GlobalScope", "Standard", "MyDialog")
         myPO = CreateScriptService("L10N", "/home/user/po_files/")
         dlg.GetTextsFromL10N(myPO)
         dlg.Execute()

Læs hjælpesiden tjenesten L10N for at få mere at vide om, hvordan PO- og POT-filer håndteres.

## OrderTabs

Set the tabulation index of a series of controls. The sequence of controls are given as an array of control names from the first to the last.

Controls with an index >= 1 are not accessible with the TAB key if:
- they are omitted from the given list
- their type is FixedLine, GroupBox or ProgressBar
- they are disabled

### Syntaks:

svc.TabsList(TabsList: num, Start: num = 1, Increment: num = 1): bool

### Parametre:

TabsList: an array of valid control names in the order of tabulation

Start: the tab index to be assigned to the 1st control in the list. Default = 1

Increment: the difference between 2 successive tab indexes. Default = 1

### Returværdi:

Returns True when successful.

### Eksempel:

##### I Basic

         oDlg.OrderTabs(Array("myListBox", "myTextField", "myNumericField"), Start := 10)

##### I Python

         dlg.OrderTabs(('myListBox', 'myTextField', 'myNumericField'), Start = 10)

## Resize

Moves the topleft corner of a dialog to new coordinates and/or modify its dimensions. All distances are expressed in AppFont units. Without arguments, the method resets the initial dimensions. Return True if the resize was successful.

### Syntaks:

svc.Resize(opt Left: num, opt Top: num, opt Width: num, opt Height: num): bool

### Parametre:

Venstre: den vandrette afstand fra det øverste, venstre hjørne

Top: den lodrette afstand fra det øverste, venstre hjørne

Bredde: bredden på den rektangel, der indeholder dialogen

Hæjde: højden på det rektangel, der indeholder dialogen

Missing arguments are left unchanged

### Eksempel:

##### I Basic

         oDlg.Resize(1000, 2000, Height := 6000) ' Width is not changed

##### I Python

         dlg.Resize(1000, 2000, Height = 6000)  # Width is not changed

## SetPageManager

Defines which controls in a dialog are responsible for switching pages, making it easier to manage the Page property of a dialog and its controls.

Dialogs may have multiple pages and the currently visible page is defined by the Page dialog property. If the Page property is left unchanged, the default visible page is equal to 0 (zero), meaning that no particular page is defined and all visible controls are displayed regardless of the value set in their own Page property.

When the Page property of a dialog is changed to some other value such as 1, 2, 3 and so forth, then only the controls whose Page property match the current dialog page will be displayed.

By using the SetPageManager method it is possible to define four types of page managers:

- List box or combo box: in this case, each entry in the list box or combo box corresponds to a page. The first item refers to Page 1, the second items refers to Page 2 and so on.

- Group of radio buttons: defines a group of radio buttons that will control which page is visible.

- Sequence of buttons: defines a set of buttons, each of which corresponding to a dialog page. This can be used to emulate a tabbed interface by placing buttons side by side in the dialog.

- Previous/Next buttons: defines which buttons in the dialog that will be used to navigate to the Previous/Next page in the dialog.

It is possible to use more than one page management mechanism at the same time.

This method is supposed to be called just once before calling the Execute method. Subsequent calls are ignored.

If successful this method returns True.

### Syntaks:

svc.SetPageManager(pilotcontrols: str = "", tabcontrols: str = "", wizardcontrols: str = "", opt lastpage: int): bool

### Parametre:

pilotcontrols: a comma-separated list of ListBox, ComboBox or RadioButton control names used as page managers. For RadioButton controls, specify the name of the first control in the group to be used.

tabcontrols: a comma-separated list of button names that will be used as page managers. The order in which they are specified in this argument corresponds to the page number they are associated with.

wizardcontrols: a comma-separated list with the names of two buttons that will be used as the Previous/Next buttons.

lastpage: the number of the last available page. It is recommended to specify this value when using the Previous/Next page manager.

### Eksempel:

Consider a dialog with three pages. The dialog has a ListBox control named "aPageList" that will be used to control the visible page. Additionally, there are two buttons named "btnPrevious" and "btnNext" that will be used as the Previous/Next buttons in the dialog.

##### I Basic

        oDlg.SetPageManager(PilotControls := "aPageList", _
                               WizardControls := "btnPrevious,btnNext", _
                               LastPage := 3)
        oDlg.Execute()

##### I Python

        dlg.SetPageManager(pilotcontrols="aPageList",
                           wizardcontrols="btnPrevious,btnNext",
                           lastpage=3)
        dlg.Execute()

## Terminate

Afslut tjenesten Dialog i den aktuelle forekomst. Returner True (sand), hvis afslutningen lykkedes.

### Syntaks:

svc.Terminate(): bool

### Eksempel:

Basic- og Python-eksemplerne herunder åbner de ikke modale dialoger DlgConsole og dlgTrace. De gemmes henholdsvis i de delte biblioteker ScriptForge og Access2Base. Luk dialog-knapperne er deaktiveret og der udføres udtrykkelig afslutning i slutningen af en kørselsproces.

I dette eksempel erstatter en knap i DlgConsole hæmmet lukning af vinduet:

##### I Basic

         oDlg = CreateScriptService("SFDialogs.Dialog","GlobalScope","ScriptForge","DlgConsole")
         oDlg.Execute(modal:=False)
         Wait 5000
         oDlg.Terminate()

##### I Python

         from time import sleep
         dlg = CreateScriptService('SFDialogs.Dialog',"GlobalScope",'Access2Base',"dlgTrace")
         dlg.Execute(modal=False)
         sleep 5
         dlg.Terminate()

Alle ScriptForge Basic-rutiner eller identifikatorer, der indledes med et understregstegn "_" er reserveret til internt brug. Det er ikke meningen, at de skal bruges i Basic-makroer eller Python-scripts.

Relaterede emner

Tjenesten SFDialogs.DialogControl

Tjenesten ScriptForge.UI (brugerflade)