BBjBatch::addCtrl

 

In BBj 3.02 and higher, the BBjBatch object is deprecated and replaced with BBjAPI::getConfig().suppressUIAckBack(1), which is no-op'd in BBj 5.0 and higher.

Description

This method adds the selected CTRL() function to the specified SysGui batch.

Syntax

Return Value

Method

void

addCtrl(int controlID, int functionID)

void

addCtrl(int controlID, int functionID, int context)

Parameters

Variable

Description

controlID

Specifies the ID of the control. A value of 0 may be used to get information about a context's window or dialog rather than an individual control or child window (as defined in the CTRL() function).

functionID

Specifies the function, numbered 0-16, as indicated in the following list (CTRL() function).

If not specified, it is the default is set according to the type of object in question. The following types behave as though function=2 (Get value) was requested: radio buttons, check boxes, list boxes, list buttons, scroll bars, menu items, and tool buttons. All others behave as though function=1 (Get text) was requested.

context

Specifies the context. If omitted, the current context is used.

Return Value

None.

Remarks

The arguments are identical to those of the CTRL() function except that the first CTRL() argument (SysGui channel) is not used.

Example

rem 'Sample program using BBjBatch

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Start buffering writes to SysGui
mySysGui!.bufferWrites()

rem 'Create a window with a title using keyboard navigation in the specified context
CONTEXT = 0
PRINT (SYSGUI)'CONTEXT'(CONTEXT),'WINDOW'(0,0,500,400,"BBj Window",$010000$,$02000000$)

rem 'Add controls on the window
PRINT (SYSGUI)'BUTTON'(101,100,100,90,30,"Red",$$)
PRINT (SYSGUI)'BUTTON'(102,200,100,90,30,"Green",$$)
PRINT (SYSGUI)'BUTTON'(103,300,100,90,30,"Blue",$$)
PRINT (SYSGUI)'CHECKBOX'(201,100,200,90,30,"Red",$0004$)
PRINT (SYSGUI)'CHECKBOX'(202,200,200,90,30,"Green",$0004$)
PRINT (SYSGUI)'CHECKBOX'(203,300,200,90,30,"Blue",$0004$)
PRINT (SYSGUI)'TEXT'(301,100,300,300,30,$$,$$)

rem 'Flush the buffered writes to SysGui
mySysGui!.flushWrites()

rem 'Obtain the instance of the BBjBatch Object
let myBatch! = mySysGui!.getMessageBatch()

rem 'Batch the SendMsg to change keyboard navigation to use ENTER as TAB
myBatch!.addSendMsg(0,1,0,"NAVIGATE = ENTER")

rem 'Process all addSendMsg functions
myBatch!.processAll()

rem 'Get the response from the SendMsg function
OLD_NAV$ = STR(myBatch!.getResponse(0))

rem 'Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,RED_BUTTON_PUSHED,CONTEXT,101)
CALLBACK(ON_BUTTON_PUSH,GREEN_BUTTON_PUSHED,CONTEXT,102)
CALLBACK(ON_BUTTON_PUSH,BLUE_BUTTON_PUSHED,CONTEXT,103)
CALLBACK(ON_CHECK_ON,RED_CHECKBOX_CHECKED,CONTEXT,201)
CALLBACK(ON_CHECK_OFF,RED_CHECKBOX_CHECKED,CONTEXT,201)
CALLBACK(ON_CHECK_ON,GREEN_CHECKBOX_CHECKED,CONTEXT,202)
CALLBACK(ON_CHECK_OFF,GREEN_CHECKBOX_CHECKED,CONTEXT,202)
CALLBACK(ON_CHECK_ON,BLUE_CHECKBOX_CHECKED,CONTEXT,203)
CALLBACK(ON_CHECK_OFF,BLUE_CHECKBOX_CHECKED,CONTEXT,203)
CALLBACK(ON_CLOSE,APP_CLOSE,CONTEXT)

rem 'Process Events
process_events

rem 'Callback routine called when the red button is pressed
RED_BUTTON_PUSHED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Set the button colors to RED
    PRINT (SYSGUI)'BRUSHCOlOR'(2),'FILL'(1),'COLORSET'(101)
    PRINT (SYSGUI)'BRUSHCOlOR'(2),'FILL'(1),'COLORSET'(102)
    PRINT (SYSGUI)'BRUSHCOlOR'(2),'FILL'(1),'COLORSET'(103)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the green button is pressed
GREEN_BUTTON_PUSHED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Set the button colors to GREEN
    PRINT (SYSGUI)'BRUSHCOlOR'(4),'FILL'(1),'COLORSET'(101)
    PRINT (SYSGUI)'BRUSHCOlOR'(4),'FILL'(1),'COLORSET'(102)
    PRINT (SYSGUI)'BRUSHCOlOR'(4),'FILL'(1),'COLORSET'(103)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the blue button is pressed
BLUE_BUTTON_PUSHED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Set the button colors to BLUE
    PRINT (SYSGUI)'BRUSHCOlOR'(1),'FILL'(1),'COLORSET'(101)
    PRINT (SYSGUI)'BRUSHCOlOR'(1),'FILL'(1),'COLORSET'(102)
    PRINT (SYSGUI)'BRUSHCOlOR'(1),'FILL'(1),'COLORSET'(103)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the red checkbox is checked
RED_CHECKBOX_CHECKED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Clear the batch
    myBatch!.clearAll()

    rem 'Batch addCtrl functions
    myBatch!.addCtrl(201,2)
    myBatch!.addCtrl(202,2)
    myBatch!.addCtrl(203,2)

    rem 'Process all addCtrol functions
    myBatch!.processAll()

    rem 'Get the responses back from the addCtrl functions
    TEXT$="Clicked Red: "
    TEXT$ = TEXT$+"Red = "+STR(DEC(myBatch!.getResponse(0)))
    TEXT$ = TEXT$+", Green= "+STR(DEC(myBatch!.getResponse(1)))
    TEXT$ = TEXT$+", Blue= "+STR(DEC(myBatch!.getResponse(2)))

    rem 'Display the selected response
    PRINT (SYSGUI)'TITLE'(301,TEXT$)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the green checkbox is checked
GREEN_CHECKBOX_CHECKED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Clear the batch
    myBatch!.clearAll()

    rem 'Batch addCtrl functions
    myBatch!.addCtrl(201,2)
    myBatch!.addCtrl(202,2)
    myBatch!.addCtrl(203,2)

    rem 'Process all addCtrol functions
    myBatch!.processAll()

    rem 'Get the responses back from the addCtrl functions
    TEXT$="Clicked Green: "
    TEXT$ = TEXT$+"Red = "+STR(DEC(myBatch!.getResponse(0)))
    TEXT$ = TEXT$+", Green= "+STR(DEC(myBatch!.getResponse(1)))
    TEXT$ = TEXT$+", Blue= "+STR(DEC(myBatch!.getResponse(2)))

    rem 'Display the selected response
    PRINT (SYSGUI)'TITLE'(301,TEXT$)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the blue checkbox is checked
BLUE_CHECKBOX_CHECKED:
    rem 'Buffer the writes to SysGui
    mySysGui!.bufferWrites()

    rem 'Clear the batch
    myBatch!.clearAll()

    rem 'Batch addCtrl functions
    myBatch!.addCtrl(201,2)
    myBatch!.addCtrl(202,2)
    myBatch!.addCtrl(203,2)

    rem 'Process all addCtrol functions
    myBatch!.processAll()

    rem 'Get the responses back from the addCtrl functions
    TEXT$="Clicked Blue: "
    TEXT$ = TEXT$+"Red = "+STR(DEC(myBatch!.getResponse(0)))
    TEXT$ = TEXT$+", Green= "+STR(DEC(myBatch!.getResponse(1)))
    TEXT$ = TEXT$+", Blue= "+STR(DEC(myBatch!.getResponse(2)))

    rem 'Display the selected response
    PRINT (SYSGUI)'TITLE'(301,TEXT$)

    rem 'Flush the writes to SysGui
    mySysGui!.flushWrites()
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

BBjSysGui

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.