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: Button: How to create a GUI button with changing text?

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


----------------------------------------------------------------------
--- Knud van Eeden --- 02 September 2020 - 10:22 pm ------------------
BBCBASIC for Windows: GUI: Control: Button: How to create a GUI button 
with changing text?
---
Use WINLIB2 library
and
the PROC_pushbutton procedure
To set the text use
 SYS "SetDlgItemText", !dlg%, <your button id number>, <your text>
---
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
 I% = 0
 pauseI% = 0
 idBoxDialogI% = FN_newdialog( "<Your dialog box title>", 20, 20, 160, 
128, 8, 504 )
 PROC_groupbox( idBoxDialogI%, "<Your group box title>", idBoxGroupI%, 
4, 4, 152, 96, &20000 )
 PROC_pushbutton( idBoxDialogI%, "Increase", idButtonActionI%, 12, 
108, 56, 14, &20001 )
 PROC_pushbutton( idBoxDialogI%, "Cancel", idButtonCancelI%, 92, 108, 
56, 14, 0 )
 PROC_showdialog( idBoxDialogI% )
 stopB% = FALSE
 I% = 1 - 1
 REPEAT
 idClickI% = 0
 ON CLOSE PROC_closedialog( idBoxDialogI% ) : QUIT
 ON ERROR PROC_closedialog( idBoxDialogI% ) : PRINT ' REPORT$ : END
 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
  I% = I% + 1
  SYS "SetDlgItemText", !idBoxDialogI%, idButtonActionI%, STR$( I% )
  PRINT "Button text value = "; STR$( I% )
 ELSE
  PRINT "Cancel button pressed"
  stopB% = TRUE
 ENDIF
 UNTIL stopB%
 PROC_closedialog( idBoxDialogI% )
 END
--- cut here: end ----------------------------------------------------
 2. -Run this program
 3. -When you click on the 'Increase' button, it will e.g.
     show an increasing number (1, 2, 3, 4, ...) as text on that button
+-------------------------+
|                         |
| <Your dialog box title> |
|                         |
+-------------------------+
|                         |
|+-<Your group box title>+|
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
||                       ||
|+-----------------------+|
|+-----------+  +--------+|
|| 1         |  | 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_pushbutton and 'initialising 
dialog boxes']
===
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
----------------------------------------------------------------------