Entry
BBCBASIC for Windows: GUI: Control: List: How to create a GUI list box? [combo box]
Sep 3rd, 2006 11:42
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 03 September 2020 - 04:07 pm ------------------
BBCBASIC for Windows: GUI: Control: List: How to create a GUI list
box? [combo box]
---
Use the WINLIB2 library,
and the PROC_listbox() procedure
To set values use repeatedly
SYS "SendDlgItemMessage", !dlg%, yourListboxIdI%, &180, 0, "your list
box item 0"
SYS "SendDlgItemMessage", !dlg%, yourListboxIdI%, &180, 0, "your list
box item 1"
...
SYS "SendDlgItemMessage", !dlg%, yourListboxIdI%, &180, 0, "your list
box item last"
To get values use
SYS "SendDlgItemMessage", !dlg%, yourListboxIdI%, &188, 0, 0 TO
yourListBoxSelectionI%
---
Steps: Overview:
1. -Create the following program
--- cut here: begin --------------------------------------------------
HIMEM = PAGE + 5000
INSTALL @lib$ + "WINLIB2"
idClickI% = 0
idBoxDialogI% = 1
idBoxGroupI% = 2
idButtonActionI% = 3
idButtonCancelI% = 4
yourListboxIdI% = 5
I% = 0
s$ = ""
pauseI% = 0
idBoxDialogI% = FN_newdialog( "<Your dialogue box title>", 20, 20,
160, 128, 8, 504 )
PROC_groupbox( idBoxDialogI%, "<Your group box title>", idBoxGroupI%,
4, 4, 152, 96, &20000 )
PROC_pushbutton( idBoxDialogI%, "OK", idButtonActionI%, 12, 108, 56,
14, &20001 )
PROC_pushbutton( idBoxDialogI%, "Cancel", idButtonCancelI%, 92, 108,
56, 14, 0 )
REM 0 means here show a sorted list
PROC_listbox( idBoxDialogI%, "", yourListboxIdI%, 41, 40, 64, 12, 0 )
PROC_showdialog( idBoxDialogI% )
ON CLOSE PROC_closedialog( idBoxDialogI% ) : QUIT
ON ERROR PROC_closedialog( idBoxDialogI% ) : PRINT ' REPORT$ : END
FOR I% = 1 TO 10
READ s$
SYS "SendDlgItemMessage", !idBoxDialogI%, yourListboxIdI%, &180, 0,
s$
NEXTI%
ON SYS idClickI% = @wparam% AND &FFFF : RETURN
REPEAT pauseI% = INKEY( 1 ) : UNTIL ( idClickI% = idButtonActionI% )
OR ( idClickI% = idButtonCancelI% ) OR ( !idBoxDialogI% = 0 )
ON SYS OFF
IF ( idClickI% = idButtonActionI% ) THEN
PRINT "OK button pressed, settings were:"'
SYS "SendDlgItemMessage", !idBoxDialogI%, yourListboxIdI%, &188, 0,
0 TO yourListBoxSelectionI%
PRINT "Listbox selection index was "; yourListBoxSelectionI%
ELSE
PRINT "Cancel button pressed"
ENDIF
PROC_closedialog( idBoxDialogI% )
END
:
DATA list item 00
DATA list item 02
DATA list item 03
DATA list item 04
DATA list item 05
DATA list item 01
DATA list item 08
DATA list item 06
DATA list item 07
DATA list item 09
--- cut here: end ----------------------------------------------------
2. -Run this program
3. -When you select an item in the list box, it will e.g.
show the number (starting from 0) of the item you selected
+-------------------------+
| |
| <Your dialog box title> |
| |
+-------------------------+
| |
|+-<Your group box title>+|
|| ||
|| ||
|| +-----------------+ ||
|| |list item 00 V | ||
|| +-----------------+ ||
|| ||
|| ||
|| ||
|| ||
|| ||
|| +------+ +--------+ ||
|| | OK | | CANCEL | ||
|| +------+ +--------+ ||
|+-----------------------+|
+-------------------------+
===
File: see also:
[file: 'dlgdemo.bbc' in the 'BBC BASIC for Windows' directory]
===
Help: see also:
[help: program: BBCBASIC for Windows v5.00a or higher: search
for 'Dialogue boxes' (look for 'PROC_listbox')]
===
Internet: see also:
---
BBCBASIC for Windows: GUI: Control: Link: Overview: Can you give an
overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/42206/fid/768
----------------------------------------------------------------------