push buttons in CRT hybride
Posted: Fri Mar 08, 2019 9:14 pm
Hi all
How can I clear all buttons when I press a button and get them back after.
Here is an example.
There is 3 buttons, A, B, C. I would like to have all buttons A, B, and C destroyed while I execute BA() and get the buttons back after the execution of BA().
Thanks
How can I clear all buttons when I press a button and get them back after.
Here is an example.
There is 3 buttons, A, B, C. I would like to have all buttons A, B, and C destroyed while I execute BA() and get the buttons back after the execution of BA().
Thanks
Code: Select all
// In the example, pushbuttons are created that
// output text in an XbpCrt window.
// How do I destroy all the buttons when I click on A ?
#include "Appevent.ch"
PROCEDURE Main
LOCAL nEvent, mp1, mp2, oXbp
CLS
// Create first pushbutton
oXbp := XbpPushButton():new( , , {50,20}, {100,40} )
oXbp:caption := "A"
oXbp:create()
oXbp:activate := {|| BA( oXbp ) }
// Create second pushbutton
oXbp := XbpPushButton():new( , , {200,20}, {100,40} )
oXbp:caption := "B"
oXbp:create()
oXbp:activate := {|| BB( oXbp ) }
// Create last pushbutton
oXbp := XbpPushButton():new( , , {350,20}, {100,40} )
oXbp:caption := "C"
oXbp:create()
oXbp:activate := {|| BC( oXbp ) }
// Event loop = Program navigation
nEvent := 0
DO WHILE nEvent <> xbeP_Close
nEvent := AppEvent( @mp1, @mp2, @oXbp )
@ 05, 22 SAY PadR( Var2Char( nEvent ), 10 )
IF VALTYPE(mp1) = "N" .AND. mp1 < 1000 .AND. mp1 <> 0
k = mp1
mp1 = 0
@ 10, 22 SAY PadR( Var2Char( k ), 10 )
k = 0
ELSE
oXbp:HandleEvent( nEvent, mp1, mp2 )
k = LASTKEY() // TO GET THE FUNCTIONS
@ 10, 22 SAY PadR( Var2Char( k ), 10 )
k = 0
ENDIF
// @ 10, 00 SAY SPACE(80) // CLEAR ON SCREEN
ENDDO
? "quitting"
inkey(1)
RETURN
FUNCTION BA( oXbp, oB2 )
oXbp:destroy()
mGET = SPACE(30)
@ 10, 12 SAY "BA "
@ 12, 12 GET mGET
SET CURSOR ON
READ
SET CURSOR OFF
CLEAR SCREEN
oXbp := XbpPushButton():new( , , {50,20}, {100,40} )
oXbp:caption := "A"
oXbp:create()
oXbp:activate := {|| BA( oXbp ) }
RETURN
FUNCTION BB( oXbp )
@ 10, 12 SAY "BB "
RETURN
FUNCTION BC( oXbp )
@ 10, 12 SAY "BC "
RETURN