IBM Lotus Symphony


对话框编辑器中控件的编程示例

以下示例针对的是一个名为“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

Loop Until sFile = ""

oLibContainer.LoadLibrary(LibName)

oLib = oLibContainer.GetByName(Libname)

oLibDialog = oLib.GetByName(DialogName)

oRuntimeDialog = CreateUnoDialog(oLibDialog)

LoadDialog() = oRuntimeDialog

End Function

显示对话框

rem global definition of variables

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 get dialog model

oDialog1Model = oDialog1.Model

REM display text of Label1

oLabel1 = oDialog1.GetControl("Label1")

MsgBox oLabel1.Text

REM set new text for control Label1

oLabel1.Text = "New Files"

REM display model properties for the control CheckBox1

oCheckBox1Model = oDialog1Model.CheckBox1

MsgBox oCheckBox1Model.Dbg_Properties

REM set new state for CheckBox1 for model of control

oCheckBox1Model.State = 1

REM display model properties for control CommandButton1

oCMD1Model = oDialog1Model.CommandButton1

MsgBox oCMD1Model.Dbg_Properties

REM display properties of control CommandButton1

oCMD1 = oDialog1.GetControl("CommandButton1")

MsgBox oCMD1.Dbg_Properties

REM execute dialog

oDialog1.Execute()

End Sub

将条目添加到 ListBox

Sub AddEntry

BasicLibraries.LoadLibrary("Tools")

oDialog1 = LoadDialog("Standard", "Dialog1")

REM adds a new entry to the 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 remove the first entry from the ListBox

oDialog1Model = oDialog1.Model

oListBox = oDialog1.GetControl("ListBox1")

oListbox.removeitems(0,1)

end sub


产品反馈 | 其他文档 | 商标