Skip to main content

Set focus on an item of a Selection-Box | set item of Selection-Box as Selected

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

Set the focus on an item of a Selection-Box | set an item of a Selection-Box as Selected

The Dialog System function SET-LIST-ITEM-STATE is not available for a SELECTION-BOX.

To set the focus on an item of a SELECTION-BOX, the Net Express Class Library must be used,

........11) creating an instance of the class selectionbox [selectionbox is class "selnbox" ], using the

..............class method fromHandle herited from the class Guibase;

..............The class method fromHandle uses a parameter which is the OBJECT's handle, in this case

...............the SELECTION-BOX's handle, retrieved with the DS function MOVE-OBJECT-HANDLE .

........12) use the instance method SetSelected of the class selectionbox

............... This method uses one parameter which is the item number to be selected

............... ( method SetSelected: Set the listbox item determined by the index to be selected )

NOTE the Netx CLASS LIBRARY can be invoked in a cobol program or directly under Dialog System.

Demo attached.

Resolution:

1) in the SCREENSET,

---> 11) load the class library  on the screenset initialized event

---> 12) on the WINDOW CREATED event ( the window in which the selection-box is located ),

               retrieve the handle of the selection-box in a field of the data-block

               ( SBHANDLE defined in data-block as C5  4.0 in this demo )

2)

--> 21 OR in a COBOL program

                  invoke selectionbox "fromHandle" using SBHANDLE

                                                  returning  SBobj

                 move SBITEMTOFOCUSON to lnkIndex

                 invoke SBobj  "SetSelected"  using lnkIndex

---> 22) OR  under Dialog System,

                    invoke directly the Class Library References classes & methods

BUTTON-SELECTED

     CLEAR-CALLOUT-PARAMETERS $NULL

     MOVE-OBJECT-HANDLE SB1 SBHANDLE

     CALLOUT-PARAMETER 1 SBHANDLE $NULL

     CALLOUT-PARAMETER 8 SB1OBJ $NULL

     INVOKE "selnbox" "fromHandle" $PARMLIST

     CLEAR-CALLOUT-PARAMETERS $NULL

     MOVE SBITEMTOFOCUSON DSLNKINDEX

                            (( !!!! DSLNKINDEX defined as C5 4.0 )in data-block ))

     CALLOUT-PARAMETER 1 DSLNKINDEX $NULL

     INVOKE SB1OBJ "SetSelected" $PARMLIST

selectionbox Method SetSelected: Set the listbox item determined by the index to be selected

SKELETON of the COBOL PROGRAM:

IDENTIFICATION DIVISION.            

PROGRAM-ID. pselbox.                 

ENVIRONMENT DIVISION.                

configuration section.               

                                    

special-names.                       

CLASS-CONTROL.                       

    selectionbox is class "selnbox".

...

WORKING-STORAGE SECTION.

          ...

       COPY "SelectionBoxFocusOnItem.CPB".

       01 SBobj                           object reference.

       01 lnkIndex PIC 9(9) COMP-5.

...

PROCEDURE DIVISION.

...

       Program-Body SECTION.

          PERFORM Call-Dialog-System

          evaluate exit-flag

             when 3

                 invoke selectionbox "fromHandle" using SBHANDLE

                                                  returning  SBobj

                 move SBITEMTOFOCUSON to lnkIndex

                 invoke SBobj  "SetSelected"  using lnkIndex

          end-evaluate

...

Old KB# 5175

0 replies

Be the first to reply!