BBjWindow::getControl

Description

Returns a BBjControl object in the BBjWindow.

Syntax

Return Value

Method

BBjControl

getControl(int ID)

BBjControl

getControl(string name)

Parameters

Variable

Description

ID

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).

name

In BBj 8.0 and higher, specifies the name of the control.

Return Value

Returns a BBjControl object.

Remarks

The getControl(stringname) version throws an exception if there are no controls, or if there is more than one control, with the specified name.

Example

REM Get a control from a Window

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 Set common addWindow param values
X=10
Y=10
WIDTH=200
HEIGHT=200

REM Create a window with a title in the current context
TITLE$="BBj Window"
REM Set the current context
mySysGui!.setContext(0)
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)

REM Add a button on the window using mnemonics
PRINT (SYSGUI)'BUTTON'(101,50,100,90,30,"Red",$$)

REM Get the button
myRedButton! = myWindow!.getControl(101)

REM Create the BBjColor Object using colorNum constant
myColorRed! = mySysGui!.makeColor(mySysGui!.RED)

REM Set the button colors to RED
myRedButton!.setBackColor(myColorRed!)

REM Register the CALLBACK routines
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

REM Callback routine called when the user closes the application window
APP_CLOSE:
RELEASE
RETURN

See Also

BBjAPI

BBjWindow

BBjControl Methods

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