Programming Examples for Controls in the Dialog Editor

JÀrgnevad nÀited on mÔeldud uuele dialoogile nimega "Dialog1". Kasuta dialoogi koostamiseks ja jÀrgmiste juhtelementide lisamiseks dialoogiredaktori tööriistakastis olevaid vahendeid: mÀrkeruut nimega "CheckBox1", pealdisevÀli nimega "Label1", nupp nimega "CommandButton1" ja loendiboks nimega "ListBox1".

Hoiatav ikoon

Objektimuutujale juhtelemendi lisamisel ole suur- ja vÀiketÀhtede kasutamisega jÀrjepidev.


Globaalne funktsioon dialoogide laadimiseks


Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object ' com.sun.star.script.XLibraryContainer
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
    If IsMissing(oLibContainer) Then
        oLibContainer = DialogLibraries
    End If
    oLibContainer.LoadLibrary(LibName)
    oLib = oLibContainer.GetByName(Libname)
    oLibDialog = oLib.GetByName(DialogName)
    oRuntimeDialog = CreateUnoDialog(oLibDialog)
    LoadDialog() = oRuntimeDialog
End Function

LoadDialog function is stored in Tools.ModuleControls available from Application Macros and Dialogs.

Dialoogi nÀitamine


REM muutujate globaalne defineerimine
Dim oDialog1 AS Object
Sub StartDialog1
    With GlobalScope.BasicLibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")
    oDialog1.Execute()
End Sub

Programmis juhtelementide omaduste lugemine vÔi muutmine


Sub Sample1
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.LoadDialog("Standard", "Dialog1")
    REM vÔta dialoogi mudel
    oDialog1Model = oDialog1.Model
    REM nÀita Label1 teksti
    oLabel1 = oDialog1.GetControl("Label1")
    MsgBox oLabel1.Text
    REM sea juhtelemendile Label1 uus tekst
    oLabel1.Text = "Uued failid"
    REM nÀita juhtelemendi CheckBox1 mudeli omadusi
    oCheckBox1Model = oDialog1Model.CheckBox1
    MsgBox oCheckBox1Model.Dbg_Properties
    REM muuda m2rkeruudu CheckBox1 olekut
    oCheckBox1Model.State = 1
    REM nÀita juhtelemendi CommandButton1 mudeli omadusi
    oCMD1Model = oDialog1Model.CommandButton1
    MsgBox oCMD1Model.Dbg_Properties
    REM nÀita juhtelemendi CommandButton1 omadusi
    oCMD1 = oDialog1.GetControl("CommandButton1")
    MsgBox oCMD1.Dbg_Properties
    REM kÀivita dialoog
    oDialog1.Execute()
End Sub

Loendiboksi kirje lisamine


Sub AddEntry
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1")
    REM lisab uue kirje loendiboksi ListBox
    oDialog1Model = oDialog1.Model
    oListBox = oDialog1.GetControl("ListBox1")
    Dim iCount as integer
    iCount = oListbox.ItemCount
    oListbox.additem("Uus element" & iCount,0)
End Sub

Loendiboksist kirje eemaldamine


Sub RemoveEntry
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1")
    REM eemalda esimene kirje loendiboksist ListBox
    oDialog1Model = oDialog1.Model
    oListBox = oDialog1.GetControl("ListBox1")
    oListbox.removeitems(0,1)
End Sub

Palun toeta meid!