Lotus Symphony 1.2
|
以下範例用於一個名為 Dialog1 的新對話框。 在對話框編輯器中,使用「控制項」浮動工具列上的工具,以建立對話框並新增下列控制項: 勾選框 (名為 CheckBox1)、標籤欄位 (名為 Label1)、 按鈕 (名為 CommandButton1) 及清單框 (名為 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