7.3 Setting Focus for the Subfile Component
If you leave the code as is, run
the Customer Inquiry application, click Find, the Customer List subfile
window of the COMPLIST component displays behind the other windows. To bring this window
to the foreground, you give it FOCUS.
Follow these steps:
- To give the Customer List subfile
window focus, you use another Component Reference part in the component
CUSTINQ to set the VISIBLE and FOCUS attributes for the Customer List window CUSTLIST.
- Now double-click on this Component
Reference part to open the Properties notebook and make the following changes:
- Under the General
tab for the attribute Part name type the value CRP1.
Deselect the Visible checkbox. If this checkbox is selected the Component
Reference part will show on the Customer Inquiry window when you run the
application.
- Under the Reference
tab for the attribute Component Name type the value COMPLIST
- For the attribute Window
Name type the value CUSTLIST
- For the attribute Part
Name type the value CUSTLIST.
- Click OK to save
and close the Properties notebook.
This completes the definition for
the Component Reference part. Now you need to complete the logic. You
need to add an indicator that tells the Customer Inquiry application that the component
COMPLIST is already started and to make the Customer List window CUSTLIST in component
COMPLIST visible and give it focus.
You need to add some code to the action subroutine that is linked to the Find
push button on the Customer Inquiry window CUSTINQ in the component Customer Inquiry
CUSTINQ.
Follow these steps:
- Use the editor and locate the PRESS
Event action subroutine for the Find push button.
- Add the following code to set the
window CUSTLIST in component COMPLIST visible:
CSRN01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq
C 'CRP1' SETATR 'VISIBLE' 'REFATTR'
C 'CRP1' SETATR '1' 'ATTRVALUE'
- To give the window focus add 2
more statements:
CSRN01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq
C 'CRP1' SETATR 'FOCUS' 'REFATTR'
C 'CRP1' SETATR '1' 'ATTRVALUE'
Remember to save your source in
the Editor.
Building and Running the
Completed Application
Now build your application and run it.
Follow these steps:
- Now build the project by selecting
Project > Build > Windows NT/95/98. If you receive any errors, you
will need to fix the errors before you can continue.
- Click on the run icon
. Enter your AS/400 user ID and password.
The Customer Inquiry window appears.
- Click Find. The
Select Customer window appears.
- Select and then double click on
one of the records. The selected customer number should be in the Customer Number CUSTNO
Entry field of the Customer Inquiry window.
- Click OK. The
Customer Information window appears with the customer information. Click OK.
- On the Customer Inquiry Window,
select File then Exit to end the application.
- Close the GUI Designer. Close any
other VisualAge RPG windows that may still be open.
Click on
to indicate that you've done all the steps.
This completes Exercise 7. You have a complete runnable
application. Since this is your last exercise, before you close the tutorial, we recommend
you do the Quiz.