SFDialogs.Dialog szolgáltatás

Tartalom

# SFDialogs.Dialog service

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.

A dialog box can be displayed in modal or in non-modal modes.

Modális módban a doboz megjelenik, és a makrófolyamat végrehajtása felfüggesztésre kerül, amíg az OK vagy a Mégse gombok valamelyikét meg nem nyomja. Eközben a dobozon végrehajtott felhasználói műveletek meghatározott műveleteket indíthatnak el.

Nem modális módban a párbeszédablak "lebeg" a felhasználói asztalon, és a makrófolyamat végrehajtása normálisan folytatódik. A nem-modális párbeszédablak bezárul, amikor a Terminate() metódussal befejezésre kerül vagy a LibreOffice munkamenet befejeződik. A nem modális párbeszédpanelekben az ablak bezárása gomb nem aktív.

A dialog box disappears from memory after its explicit termination.

The SFDialogs.Dialog service is closely related to the SFDialogs.DialogControl service.

## Service invocation and usage

Before using the Dialog service the ScriptForge library needs to be loaded or imported:

• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
• Python scripts require an import from scriptforge module:
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" for preinstalled libraries or a window name as defined by ScriptForge.UI service. Empty string "" default value stands for the current document.

Library: The case-sensitive name of a library contained in the container. Default value is "Standard".

DialogName: A case-sensitive string designating the dialog.

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")
          '... controls initialization goes here...
          lButton = oDlg.Execute()
          'Default mode = Modal
          If lButton = oDlg.OKBUTTON Then
          '... Process controls and do what is needed here
          End If
          oDlg.Terminate()

Vagy Python használatával:

        dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole')
        # ... controls initialization goes here...
        rc = dlg.Execute()
        # Default mode is Modal
        if rc == dlg.OKBUTTON:
            # ... Process controls and do what is needed here
        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

A Dialog szolgáltatás egy példánya a SFDialogs.DialogEvent szolgáltatáson keresztül kérhető le, feltéve, hogy a párbeszédet a Dialog szolgáltatással kezdeményezték. Az alábbi példában az oDlg tartalmazza a Dialog példányt, amely a párbeszédeseményt kiváltotta.

        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

A párbeszédesemények eseménykezelőjének létrehozásakor jó gyakorlat, ha a hibákat magában a szubrutinban kezeli. Tegyük fel például, hogy az alábbi eseménykezelőt akkor hívjuk meg, amikor a párbeszédablakban megnyomjuk az egérgombot.

        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))

## Tulajdonságok

Név | Írásvédett | Típus | Leírás
--- | --- | --- | ---
OKBUTTON | Igen | Integer | Value = 1. An OK button was pressed.
CANCELBUTTON | Igen | Integer | Value = 0. A Cancel button was pressed.
Caption | Nem | String | Specify the title of the dialog.
Height | Nem | Long | Specify the height of the dialog box.
Modal | Igen | Boolean | Specifies if the dialog box is currently in execution in modal mode.
Name | Igen | String | The name of the dialog
Page | Nem | Integer | A dialog may have several pages that can be traversed by the user step by step. The Page property of the Dialog object defines which page of the dialog is active.
Visible | Nem | Boolean | Specify if the dialog box is visible on the desktop. By default it is not visible until the Execute() method is run and visible afterwards.
XDialogModel | Igen | UNO object | The UNO object representing the dialog model. Refer to XControlModel and UnoControlDialogModel in Application Programming Interface (API) documentation for detailed information.
XDialogView | Igen | UNO object | The UNO object representing the dialog view. Refer to XControl and UnoControlDialog in Application Programming Interface (API) documentation for detailed information.
Width | Nem | Long | Specify the width of the dialog box.

## Esemény tulajdonságai

On… event properties are URI strings that reference a script triggered for an event. Read its specification in the scripting framework URI specification.

Név | Basic IDE leírása
--- | ---
OnFocusGained | Amikor a fókuszt megkapja
OnFocusLost | Amikor a fókuszt elveszti
OnKeyPressed | Billentyű lenyomva
OnKeyReleased | Billentyű felengedve
OnMouseDragged | Mouse moved while key presses
OnMouseEntered | Egér belül
OnMouseExited | Egér kívül
OnMouseMoved | Egér mozdult
OnMousePressed | Egérgomb lenyomása
OnMouseReleased | Egérgomb elengedése

Tip: All On… properties can be set programmatically.
How to display data in a tree control example in LibreOffice Wiki demonstrates such.

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 CreateTabPageContainer | CreateTextField CreateTimeField CreateTreeControl EndExecute Execute GetTextsFromL10N ImportControl OrderTabs Resize SetPageManager Terminate

TabPageContainer controls are not available in Dialog Editor.

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

Set the focus on the current Dialog instance. Return True if focusing was successful.

This method is called from a dialog or control event, or when a dialog is displayed in non-modal mode.

### Szintaxis:

svc.Activate(): bool

### Példa:

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

Python and LibreOffice Basic examples both assume that the dialog is stored in current document's Standard library.

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

## Center

Centers the current dialog instance in the middle of a parent window. Without arguments, the method centers the dialog in the middle of the current window.

Returns True when successful.

### Szintaxis:

svc.Center(opt Parent: obj): bool

### Paraméterek:

Parent: An optional object that can be either …

- a ScriptForge dialog object

- a ScriptForge document (Calc, Base, ...) object

### Példa:

##### A Basic nyelvben

         Sub TriggerEvent(oEvent As Object)
             Dim oDialog1 As Object, oDialog2 As Object, lExec As Long
             Set oDialog1 = CreateScriptService("DialogEvent", oEvent) ' The dialog that caused the event
             Set oDialog2 = CreateScriptService("Dialog", ...) ' Open a second dialog
             oDialog2.Center(oDialog1)
             lExec = oDialog2.Execute()
             Select Case lExec
                 ...
         End Sub

##### A Python nyelvben

         def triggerEvent(event: uno):
           dlg1 = CreateScriptService('DialogEvent.Dialog', event)  # The dialog having caused the event
           dlg2 = CreateScriptService('Dialog', ...)  # Open a second dialog
           dlg2.Center(dlg1)
           rc = dlg2.Execute()
           if rc is False:
             # ...

## CloneControl

Duplicate an existing control of any type in the actual dialog. The duplicated control is left unchanged and can be relocated.

### Szintaxis:

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

### Paraméterek:

SourceName: The name of the control to duplicate.

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.

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## Controls

Return either:

- the list of the controls contained in the dialog

- a DialogControl class instance based on its name

### Szintaxis:

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

svc.Controls(controlname: str): svc

### Paraméterek:

ControlName : A valid control name as a case-sensitive string. If absent, the list of control names is returned as a zero-based array.

### Példa:

          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.

### Szintaxis:

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

### Paraméterek:

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)

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateCheckBox

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

### Szintaxis:

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

### Paraméterek:

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.

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateComboBox

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

### Szintaxis:

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

### Paraméterek:

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)

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateCurrencyField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateDateField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateFileControl

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

### Szintaxis:

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

### Paraméterek:

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"

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateFixedLine

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

### Szintaxis:

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

### Paraméterek:

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".

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateFixedText

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

### Szintaxis:

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

### Paraméterek:

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"

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateFormattedField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateGroupBox

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

### Szintaxis:

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

### Paraméterek:

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.

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateHyperlink

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

### Szintaxis:

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

### Paraméterek:

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"

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateImageControl

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

### Szintaxis:

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

### Paraméterek:

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"

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateListBox

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateNumericField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreatePatternField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateProgressBar

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateRadioButton

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateScrollBar

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateTableControl

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateTabPageContainer

Creates a new control of type TabPageContainer in the current dialog. Tabs are spread over separate lines inside the dialog when necessary. Multiple TabPageContainer are not supported.

TagePageContainer control creation comes always last in a dialog creation.

### Szintaxis:

svc.CreateTabPageContainer(ControlName: str, Place: any, TabHeaders: str[1..*], Border: str = "3D"): svc

### Paraméterek:

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.

TabHeaders: An array of strings defining each individual label for tabs

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

         Set myTabPageContainer = oDlg.CreateTabPageContainer("someContainer", Array(20, 20, 60, 15), TabHeaders := Array("Modules", "Dialogs", "Libraries"))

##### A Python nyelvben

         myTabPageContainer = dlg.CreateTabPageContainer('theTabs', TabHeaders=('Modules', 'Dialogs', 'Libraries'), place=(20, 20, 60, 15))

## CreateTextField

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

### Szintaxis:

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

### Paraméterek:

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 = "")

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateTimeField

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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## CreateTreeControl

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

### Szintaxis:

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

### Paraméterek:

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"

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## EndExecute

Ends the display of a modal dialog and gives back the argument as return value for the current Execute() running action.

EndExecute() is usually contained in the processing of a macro triggered by a dialog or control event.

### Szintaxis:

svc.EndExecute(returnvalue: int)

### Paraméterek:

returnvalue: The value passed to the running Execute() method.

### Példa:

##### A Basic nyelvben

          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

##### A Python nyelvben

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

Above com.sun.star.lang.EventObject mentions are optional. Such annotations help identify LibreOffice Application Programming Interface (API).

## Execute

Display the dialog box and, when modal, wait for its termination by the user. The returned value is either:

- 0 : Cancel button pressed

- 1 : OK button pressed

- Otherwise the dialog stopped with an EndExecute() statement issued by a dialog or control event

For non-modal dialog boxes the method always returns 0 and the execution of the macro continues.

### Szintaxis:

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

### Paraméterek:

modal: False when non-modal dialog. Default = True.

### Példa:

In this Basic example myDialog dialog is stored in current document's Standard library.

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

This Python code displays DlgConvert modal dialog from Euro shared Basic library.

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

## GetTextsFromL10N

Replaces all fixed text strings in a dialog by their translated versions based on a L10N service instance. This method translates the following strings:

- The title of the dialog.

- The caption of the following control types: Button, CheckBox, FixedLine, FixedText, GroupBox and RadioButton.

- Static strings in ListBoxes and ComboBoxes.

- The tooltip or help text displayed when the mouse hovers over the control.

The method returns True if successful.

To create a list of translatable strings in a dialog use the AddTextsFromDialog method from the L10N service.

### Szintaxis:

svc.GetTextsFromL10N(l10n: svc): bool

### Paraméterek:

l10n: A L10N service instance from which translated strings will be retrieved.

### Példa:

The following example loads translated strings and applies them to the dialog "MyDialog".

##### A Basic nyelvben

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

##### A Python nyelvben

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

Read the L10N service help page to learn more about how PO and POT files are handled.

## ImportControl

Import and duplicate an existing control of any type from one dialog to the actual dialog. The duplicated control is left unchanged. The new control can be renamed and relocated. Events handlers, when present, may be imported too.

### Szintaxis:

svc.ImportControl(SourceDialog: svc, SourceName: str, opt ControlName: str, Page: num = 0, OffsetX: num = 0, OffsetY:num = 0, IncludeOnProperties: bool = False): svc

### Paraméterek:

SourceDialog: an SFDialogs.Dialog class instance.

SourceName: the name of the control to import.

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

Page: the page number of the new control. Default = 0

OffsetX, OffsetY: the number of pixels to add to the source control coordinates in "Map AppFont" units. Default = 0, may be negative.

IncludeOnProperties: include the On... event properties. Default = False.

### Return type:

An instance of SFDialogs.DialogControl service or Nothing.

### Példa:

##### A Basic nyelvben

         Set mCtrl = oDlg.ImportControl(srceDlg, "someCtrlName")

##### A Python nyelvben

         dlg.ImportControl(srceDlg, 'aCtrlName', includeOnProperties=true)

## 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

### Szintaxis:

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

### Paraméterek:

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

### Return type:

Returns True when successful.

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

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

## Resize

A párbeszédablak bal felső sarkát új koordinátákra mozgatja és/vagy módosítja a méreteit. Minden távolság AppFont egységekben van megadva. Argumentumok nélkül a metódus visszaállítja a kezdeti méreteket. True értéket ad vissza, ha az átméretezés sikeres volt.

### Szintaxis:

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

### Paraméterek:

Left: the horizontal distance from the top-left corner

Top: the vertical distance from the top-left corner

Width: the width of the rectangle containing the dialog

Height: the height of the rectangle containing the dialog

Missing arguments are left unchanged

### Példa:

##### A Basic nyelvben

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

##### A Python nyelvben

         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.

A párbeszédablakoknak több oldala is lehet, és az aktuálisan látható oldalt a Page párbeszédablak-tulajdonság határozza meg. Ha a Page tulajdonság változatlanul marad, az alapértelmezett látható oldal értéke 0 (nulla), ami azt jelenti, hogy nincs meghatározott oldal definiálva, és minden látható vezérlőelem megjelenik, függetlenül a saját Page tulajdonságukban beállított értéktől.

Ha a párbeszédablak Page tulajdonságát más értékre, például 1, 2, 3 stb. értékre változtatjuk, akkor csak azok a vezérlők jelennek meg, amelyek Page tulajdonsága megfelel az aktuális párbeszédablak oldalának.

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

- Listapanel vagy kombinált lista: ebben az esetben a listapanel vagy kombinált lista minden egyes bejegyzése egy oldalnak felel meg. Az első elem az 1. oldalra, a második elem a 2. oldalra utal, és így tovább.

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

- Gombok sorozata: gombok egy sorát határozza meg, amelyek mindegyike egy párbeszédablak oldalának felel meg. Ez egy füles felület emulálására használható a párbeszédablakban egymás mellé helyezett gombok segítségével.

- 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.

### Szintaxis:

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

### Paraméterek:

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: az oldalkezelőként használt gombok neveinek vesszővel elválasztott listája. Az ebben az argumentumban megadott sorrendjük megfelel a hozzájuk tartozó oldalszámnak.

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.

### Példa:

Tekintsünk egy három oldalas párbeszédablakot. A párbeszédablak rendelkezik egy ListBox vezérlővel, amelynek neve "aPageList", és amely a látható oldal vezérlésére szolgál. Ezenkívül van két, "btnPrevious" és "btnNext" nevű gomb, amelyek a párbeszédablak Előző/Következő gombjaiként lesznek használva.

##### A Basic nyelvben

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

##### A Python nyelvben

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

## Terminate

Terminate the Dialog service for the current instance. Return True if the termination was successful.

### Szintaxis:

svc.Terminate(): bool

### Példa:

Az alábbi Basic és Python példák megnyitják a DlgConsole és dlgTrace nem modális párbeszédablakokat. Ezek a ScriptForge és Access2Base megosztott könyvtárakban vannak tárolva. A párbeszédablakok bezárására szolgáló gombok le vannak tiltva, és a folyamat végén explicit befejezés történik.

In this example a button in DlgConsole is substituting inhibited window closing:

##### A Basic nyelvben

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

##### A Python nyelvben

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

All ScriptForge Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.

Kapcsolódó témakörök

SFDialogs.DialogControl service

ScriptForge.UI service

Támogasson minket!