ZQBAD‖SFDialogs.Dialog service

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

tip

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


LVjBj‖In modal mode, the box is displayed and the execution of the macro process is suspended until one of the OK or Cancel buttons is pressed. In the meantime, user actions executed on the box can trigger specific actions.

FFTSj‖In non-modal mode, the dialog box is "floating" on the user desktop and the execution of the macro process continues normally. A non-modal dialog closes when it is terminated with the Terminate() method or when the LibreOfficeDev session ends. The window close button is inactive in non-modal dialogs.

GrpyR‖A dialog box disappears from memory after its explicit termination.

tip

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


CByHp‖Service invocation and usage

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

note

gF8D8‖• 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


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

KyBGV‖Container: "GlobalScope" for preinstalled libraries or a window name as defined by ScriptForge.UI service. Empty string "" default value stands for the current document.

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

FSp5N‖DialogName: A case-sensitive string designating the dialog.

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

VD35X‖Or using Python:


    dlg = CreateScriptService('SFDialogs.Dialog', 'GlobalScope', 'ScriptForge', 'dlgConsole')
    knENA‖# ... controls initialization goes here...
    rc = dlg.Execute()
    2PTBU‖# Default mode is Modal
    if rc == dlg.OKBUTTON:
    irQ8e‖    # ... Process controls and do what is needed here
    dlg.Terminate()
  
note

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


tip

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


5PbBk‖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":

B82Et‖DialogName: A case-sensitive string designating the dialog.

VEJtV‖Place: Window location of the dialog being either :

HkCDF‖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
  

sKdLk‖Or using Python:


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

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

8iyqo‖Retrieving the Dialog instance that triggered a dialog event

BVcDA‖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
  

4FBts‖Or using Python:


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

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

KCDyk‖Handling exceptions in event handlers

9kZzz‖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)
    PatCo‖    ' Process the event
        Exit Sub
    Catch:
        MsgBox SF_Exception.Description
        SF_Exception.Clear
    End Sub
  
tip

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


fJoDn‖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)
    GJ42e‖        # Process the event
        except Exception as e:
    yBzrf‖        # The object "bas" is an instance of the Basic service
            bas.MsgBox(str(e))
  

nXGkZ‖Properties

zVLEC‖Name

FBCFG‖ReadOnly

ByVDE‖Type

8AUBJ‖Description

OKBUTTON

iZZec‖Yes

Integer

av994‖Value = 1. An OK button was pressed.

CANCELBUTTON

GKcTG‖Yes

Integer

z4BZ4‖Value = 0. A Cancel button was pressed.

Caption

cThsX‖No

String

48bDT‖Specify the title of the dialog.

Height

2pjyZ‖No

Long

3Rypn‖Specify the height of the dialog box.

Modal

KD2zy‖Yes

Boolean

ABrxD‖Specifies if the dialog box is currently in execution in modal mode.

Name

sA5Nj‖Yes

String

JoAYu‖The name of the dialog

Page

jcbwB‖No

Integer

Tfrah‖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

FZG3n‖No

Boolean

3sRE5‖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

w6DwG‖Yes

UNO
object

2DaKv‖The UNO object representing the dialog model. Refer to XControlModel and UnoControlDialogModel in Application Programming Interface (API) documentation for detailed information.

XDialogView

YFYi4‖Yes

UNO
object

yexon‖The UNO object representing the dialog view. Refer to XControl and UnoControlDialog in Application Programming Interface (API) documentation for detailed information.

Width

S4DWL‖No

Long

G6Qsw‖Specify the width of the dialog box.


q8eyc‖Event properties

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

XCC7C‖Name

eFrre‖Read/Write

uW85z‖Basic IDE Description

OnFocusGained

dFkbN‖Yes

aKBvg‖When receiving focus

OnFocusLost

4FBaJ‖Yes

8U7FZ‖When losing focus

OnKeyPressed

wBCKi‖Yes

CK5vU‖Key pressed

OnKeyReleased

gXJGu‖Yes

CJwi7‖Key released

OnMouseDragged

wS7GH‖Yes

GcDU7‖Mouse moved while key presses

OnMouseEntered

eUS49‖Yes

QrByH‖Mouse inside

OnMouseExited

CRGTF‖Yes

69s4B‖Mouse outside

OnMouseMoved

ojLRr‖Yes

XaS8A‖Mouse moved

OnMousePressed

MnMUF‖Yes

NtqPz‖Mouse button pressed

OnMouseReleased

czknv‖Yes

J2uzg‖Mouse button released


warning

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


9uiAA‖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


note

GbtVM‖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

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

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

FVEx2‖Syntax:

svc.Activate(): bool

EFSA4‖Example:


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

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


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

Center

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

xEJEH‖Returns True when successful.

FVEx2‖Syntax:

svc.Center(opt Parent: obj): bool

WADQ4‖Parameters:

Woksx‖Parent: An optional object that can be either …

EFSA4‖Example:

3aa4B‖In Basic

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

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

CloneControl

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

FVEx2‖Syntax:

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

WADQ4‖Parameters:

CCUpB‖SourceName: The name of the control to duplicate.

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

      Set myButton2 = oDlg.CloneControl("Button1", "Button2", 30, 30)
   
BenDd‖In Python

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

Controls

4qLn9‖Return either:

FVEx2‖Syntax:

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

svc.Controls(controlname: str): svc

WADQ4‖Parameters:

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

EFSA4‖Example:


      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

YWeDt‖Create a new control of type Button in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myButton = oDlg.CreateButton("Button1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

CreateCheckBox

ztBSW‖Create a new control of type CheckBox in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateComboBox

c7gRE‖Create a new control of type ComboBox in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

EBEZu‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateCurrencyField

CzvWq‖Create a new control of type CurrencyField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

CzJFF‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateDateField

WEbJY‖Create a new control of type DateField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

WJDCR‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateFileControl

xP5vF‖Create a new control of type FileControl in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

Z8TBR‖Border: "3D" (default) or "FLAT" or "NONE"

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myFileControl = oDlg.CreateFileControl("FileControl1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

CreateFixedLine

GB9hB‖Create a new control of type FixedLine in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

FstFf‖Orientation: "H[orizontal]" or "V[ertical]".

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateFixedText

fQ7cw‖Create a new control of type FixedText in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

qWysV‖Border: "NONE" (default) or "FLAT" or "3D"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateFormattedField

BFyLA‖Create a new control of type FormattedField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

Egi57‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateGroupBox

fnPFv‖Create a new control of type GroupBox in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myGroupBox = oDlg.CreateGroupBox("GroupBox1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

CreateHyperlink

mSbuC‖Create a new control of type Hyperlink in the current dialog.

FVEx2‖Syntax:

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

ZLjCH‖Border: "NONE" (default) or "FLAT" or "3D"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateImageControl

RSnLh‖Create a new control of type ImageControl in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

oYoCP‖Border: "3D" (default) or "FLAT" or "NONE"

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myImageControl = oDlg.CreateImageControl("ImageControl1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

CreateListBox

qBHYH‖Create a new control of type ListBox in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

EJiPj‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateNumericField

2td5s‖Create a new control of type NumericField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

zzVVQ‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreatePatternField

XDRog‖Create a new control of type PatternField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

hHGWt‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateProgressBar

amC4c‖Create a new control of type ProgressBar in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

4BBzC‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateRadioButton

orPfn‖Create a new control of type RadioButton in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateScrollBar

FXgot‖Create a new control of type ScrollBar in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

eqt7D‖Orientation: H[orizontal] or V[ertical]

ukFA2‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateTableControl

PfwHb‖Create a new control of type TableControl in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

iFFvS‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

7CcWA‖ScrollBars: H[orizontal] or V[ertical] or B[oth] or N[one] (default). Scrollbars appear dynamically when they are needed.

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

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

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

CreateTextField

Afff6‖Create a new control of type TextField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

VeTxt‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic
Set myTextField = oDlg.CreateTextField("TextField1", Array(20, 20, 120, 50), MultiLine := True)
   
BenDd‖In Python

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

CreateTimeField

eFECE‖Create a new control of type TimeField in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

ADdEz‖Border: "3D" (default) or "FLAT" or "NONE"

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

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

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myTimeField = oDlg.CreateTimeField("TimeField1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

CreateTreeControl

CcyYS‖Create a new control of type TreeControl in the current dialog.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

GDYGN‖Place: either …

3Mdpm‖All elements are expressed in Map AppFont units.

KBrUN‖Border: "3D" (default) or "FLAT" or "NONE"

GePPP‖Return value:

kjvhr‖An instance of SFDialogs.DialogControl service or Nothing.

EFSA4‖Example:

3aa4B‖In Basic

     Set myTreeControl = oDlg.CreateTreeControl("TreeControl1", Array(20, 20, 60, 15))
   
BenDd‖In Python

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

EndExecute

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

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

FVEx2‖Syntax:

svc.EndExecute(returnvalue: int)

WADQ4‖Parameters:

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

EFSA4‖Example:

3aa4B‖In 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
   
BenDd‖In Python

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

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


Execute

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

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

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

EFSA4‖Example:

fGatm‖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
   

ouEVN‖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

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

JixXU‖The method returns True if successful.

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

FVEx2‖Syntax:

svc.GetTextsFromL10N(l10n: svc): bool

WADQ4‖Parameters:

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

EFSA4‖Example:

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

3aa4B‖In Basic

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

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

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


OrderTabs

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

warning

GfyZ2‖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


FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

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

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

GePPP‖Return value:

DFWjc‖True when successful.

EFSA4‖Example:

3aa4B‖In Basic

     oDlg.OrderTabs(Array("myListBox", "myTextField", "myNumericField"), Start := 10)
   
BenDd‖In Python

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

Resize

4FcCi‖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.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

XRdLE‖Left: the horizontal distance from the top-left corner

FcTcU‖Top: the vertical distance from the top-left corner

uX7ps‖Width: the width of the rectangle containing the dialog

ApqA8‖Height: the height of the rectangle containing the dialog

nEvvd‖Missing arguments are left unchanged

EFSA4‖Example:

3aa4B‖In Basic

     aADKy‖oDlg.Resize(1000, 2000, Height := 6000) ' Width is not changed
   
BenDd‖In Python

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

SetPageManager

6DRxV‖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.

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

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

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

tip

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


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

BovE9‖ If successful this method returns True.

FVEx2‖Syntax:

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

WADQ4‖Parameters:

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

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

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

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

EFSA4‖Example:

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

3aa4B‖In Basic

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

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

Terminate

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

FVEx2‖Syntax:

svc.Terminate(): bool

EFSA4‖Example:

CgAYf‖Below Basic and Python examples open DlgConsole and dlgTrace non-modal dialogs. They are respectively stored in ScriptForge and Access2Base shared libraries. Dialog close buttons are disabled and explicit termination is performed at the end of a running process.

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

3aa4B‖In Basic

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

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

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