დიალოგის რედაქტორის საკონტროლო ელემენტების პროგრამირების მაგალითები
The following examples are for a new dialog called "Dialog1". Use the tools on the Toolbox bar in the dialog editor to create the dialog and add the following controls: a Check Box called "CheckBox1", a Label Field called "Label1", a Button called "CommandButton1", and a List Box called "ListBox1".
ყურადღებით იყავით მთავრულ და ქვედა რეგისტრის ასოებთან როცა აბავთ საკონტროლო ელემენტებს ობიექტის ცვლადებს.
ჩატვირთვის დიალოგების გლობალური ფუნქციები
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object
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
დიალოგის ჩვენება
rem ცვლადების გლობალური განსაზღვრა
Dim oDialog1 AS Object
Sub StartDialog1
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
oDialog1.Execute()
End Sub
პროგრამაში საკონტროლო ელემენტების წაკითხვა ან რედაქტირება
Sub Sample1
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM დიალოგის მოდელის მიღება
oDialog1Model = oDialog1.Model
REM Label1-ის ტექსტის ჩვენება
oLabel1 = oDialog1.GetControl("Label1")
MsgBox oLabel1.Text
REM Label1 კონტროლისთვის ახალი ტექსტის შექმნა
oLabel1.Text = "New Files"
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
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM დაამატე ახალი ჩანაწერი ListBox-ში
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
Dim iCount as integer
iCount = oListbox.ItemCount
oListbox.additem("New Item" & iCount,0)
End Sub
მოაშორე ჩანაწერი ListBox-დან
Sub RemoveEntry
BasicLibraries.LoadLibrary("Tools")
oDialog1 = LoadDialog("Standard", "Dialog1")
REM მოაშორე პირველი ჩანაწერი ListBox-დან
oDialog1Model = oDialog1.Model
oListBox = oDialog1.GetControl("ListBox1")
oListbox.removeitems(0,1)
End Sub