This code displays a dialogbox with a listbox:
Code: Select all
REM ***** BASIC *****
Sub Main
GlobalScope.BasicLibraries.LoadLibrary("Tools")
GlobalScope.BasicLibraries.LoadLibrary("XrayTool")
DialogLibraries.LoadLibrary("Standard")
oLib = DialogLibraries.GetByName("Standard")
oDlg = Dlg_Create( 80, 80, 120, 40, "Dynamic dialog" )
aContent = array("Albert", "Bernard", "Charly")
Dlg_Listbox(oDlg, 10, 10, 100, 12, 1, "myList", aContent, "myList")
oDlg.setVisible(true)
oDlg.execute()
End Sub
Function Dlg_Create( x As Long, y As Long, w As Long, h As Long, cTitle As String )
oModel = createUnoService( "com.sun.star.awt.UnoControlDialogModel" )
With oModel
.PositionX = x
.PositionY = y
.Width = w
.Height = h
.Title = cTitle
End with
oCtrl = createUnoService( "com.sun.star.awt.UnoControlDialog" )
oCtrl.setModel( oModel )
Dlg_Create = oCtrl
End function
Sub Dlg_Listbox(oDlg as object, x As Long, y As Long, w As Long, h As Long, _
nIndex as long, cName As String, _
content As Array, cListener As String )
oModel = oDlg.Model.createInstance( "com.sun.star.awt.UnoControlListBoxModel" )
With oModel
.PositionX = x
.PositionY = y
.Width = w
.Height = h
.Name = cName
.TabIndex = nIndex
.DropDown = 1
End with
oDlg.Model.insertByName( cName, oModel )
oCtrl = oDlg.getControl( cName )
oCtrl.addItems( content(), 0)
oCtrl.selectItemPos(1, true)
oActionListener = CreateUnoListener( cListener + "_", "com.sun.star.awt.XActionListener" )
oCtrl.addActionListener( oActionListener )
End Sub
Sub MyList_actionPerformed(oEve)
'dummy
End Sub
Sub MyList_itemStateChanged
'dummy
End Sub
Thanks for your insight