ການຊ່ວຍເຫຼືອ LibreOffice 26.2
ຕົວຢ່າງຕໍ່ໄປນີ້ແມ່ນສຳລັບ ໄດອະລັອກ ໃໝ່ທີ່ຊື່ວ່າ "Dialog1". ໃຫ້ໃຊ້ເຄື່ອງມືໃນແຖບ ກ່ອງເຄື່ອງມື (Toolbox) ໃນຕົວແກ້ໄຂໄດອະລັອກເພື່ອສ້າງໄດອະລັອກ ແລະ ເພີ່ມຄອນໂທຣລດັ່ງຕໍ່ໄປນີ້: ຊ່ອງໝາຍ (Check Box) ທີ່ຊື່ວ່າ "CheckBox1", ຟິລປ້າຍຊື່ (Label Field) ທີ່ຊື່ວ່າ "Label1", ປຸ່ມ (Button) ທີ່ຊື່ວ່າ "CommandButton1", ແລະ ລາຍການເລືອກ (List Box) ທີ່ຊື່ວ່າ "ListBox1".
ກະລຸນາກວດສອບຕົວອັກສອນພິມໃຫຍ່ ແລະ ພິມນ້ອຍໃຫ້ຖືກຕ້ອງ ເມື່ອທ່ານກຳນົດຄອນໂທຣລໃຫ້ກັບຕົວປ່ຽນວັດຖຸ.
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 ຖືກເກັບໄວ້ໃນ Tools.ModuleControls ເຊິ່ງມີໃຫ້ໃຊ້ຈາກມາໂຄຣ ແລະ ໄດອະລັອກຂອງໂປຣແກຣມ.
REM ການກຳນົດຕົວປ່ຽນແບບໂກລບອນ (global)
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
Sub Sample1
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = Tools.LoadDialog("Standard", "Dialog1")
REM ດຶງແບບຈຳລອງໄດອະລັອກ (dialog model)
oDialog1Model = oDialog1.Model
REM ສະແດງຂໍ້ຄວາມຂອງ Label1
oLabel1 = oDialog1.GetControl("Label1")
MsgBox oLabel1.Text
REM ຕັ້ງຂໍ້ຄວາມໃໝ່ສຳລັບຄອນໂທຣລ Label1
oLabel1.Text = "ໄຟລ໌ໃໝ່"
REM ສະແດງຄຸນສົມບັດແບບຈຳລອງສຳລັບຄອນໂທຣລ CheckBox1
oCheckBox1Model = oDialog1Model.CheckBox1
MsgBox oCheckBox1Model.Dbg_Properties
REM ຕັ້ງສະຖານະໃໝ່ສຳລັບ CheckBox1 ໃນແບບຈຳລອງຄອນໂທຣລ
oCheckBox1Model.State = 1
REM ສະແດງຄຸນສົມບັດແບບຈຳລອງສຳລັບຄອນໂທຣລ CommandButton1
oCMD1Model = oDialog1Model.CommandButton1
MsgBox oCMD1Model.Dbg_Properties
REM ສະແດງຄຸນສົມບັດຂອງຄອນໂທຣລ CommandButton1
oCMD1 = oDialog1.GetControl("CommandButton1")
MsgBox oCMD1.Dbg_Properties
REM ປະມວນຜົນໄດອະລັອກ
oDialog1.Execute()
End Sub
Sub AddEntry
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1")
REM ເພີ່ມລາຍການໃໝ່ເຂົ້າໃນ ListBox
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
Dim iCount as integer
iCount = oListbox.ItemCount
oListbox.additem("ລາຍການໃໝ່" & iCount,0)
End Sub
Sub RemoveEntry
With GlobalScope.Basiclibraries
If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
End With
oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1")
REM ລົບລາຍການທຳອິດອອກຈາກ ListBox
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
oListbox.removeitems(0,1)
End Sub