faqts : Computers : Programming : Languages : Bbcbasic

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

BBCBASIC for Windows: GUI: Control: Combobox: How to create a GUI combo box? [list box]

Sep 3rd, 2006 11:37
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 03 September 2020 - 08:26 pm ------------------
BBCBASIC for Windows: GUI: Control: Combobox: How to create a GUI 
combo box? [list box]
---
Use the WINLIB2 library,
and the PROC_combobox() procedure
and to set values use repeatedly
 SYS "SendDlgItemMessage", !idBoxDialogI%, yourComboBoxIdI%, &143, 
0, "your list box item 0"
 SYS "SendDlgItemMessage", !idBoxDialogI%, yourComboBoxIdI%, &143, 
0, "your list box item 1"
 ...
 SYS "SendDlgItemMessage", !idBoxDialogI%, yourComboBoxIdI%, &143, 
0, "your list box item last"
 and follow this once after the last with
 SYS "SendDlgItemMessage", !idBoxDialogI%, yourComboBoxIdI%, &14E, 0, 0
and to get values use
  DIM textI% 100
  SYS "GetDlgItemText", !idBoxDialogI%, yourComboBoxIdI%, textI%, 255 
TO Len%
  textI%?Len%=13
  PRINT "Combobox selection was """$textI%""""
---
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
 yourComboBoxIdI% = 5
 I% = 0
 s$ = ""
 pauseI% = 0
 textI% = 0
 DIM textI% 100
 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 setting the last parameter in PROC_combox to:
 REM  &3 creates a drop down list
 REM  &100 causes the items in the list to be sorted into alphabetical 
order
 REM  &20000 causes the combo box to be the first item in a new group.
 REM  The values can be combined by adding them (e.g. &20100 combines 
the last 2 options)
 REM
 REM Here &3 + &100 = &103 means here show a drop down list and sorted
 PROC_combobox( idBoxDialogI%, "", yourComboBoxIdI%, 41, 40, 64, 12, 
&103 )
 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%, yourComboBoxIdI%, &143, 0, 
s$
 NEXTI%
 SYS "SendDlgItemMessage", !idBoxDialogI%, yourComboBoxIdI%, &14E, 0, 0
 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 "GetDlgItemText", !idBoxDialogI%, yourComboBoxIdI%, textI%, 255 
TO Len%
  textI%?Len%=13
  PRINT "Combobox selection was """$textI%""""
 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_combobox')]
===
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
----------------------------------------------------------------------