Consultor Eletrônico



Kbase 12547: How to create Static Persistent Windows with the UIB
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to create Static Persistent Windows with the UIB

Creating Static Persistent Windows with the PROGRESS UIB
11/10/93 by GFS

This document describes a method that can be used to reliably pop-
up additional PROGRESS windows from an existing PROGRESS window
using source code generated with the PROGRESS UIB.

The pop-up window will be referred to in this document as a 'Static
Persistent Window' (SPW). This type of window can be used in
various ways. In the attached example, a SPW is used to browse
Order information for a Customer which is displayed in its own
PROGRESS Window. The Customer window as known as the 'Application
Window' (AW) and generally serves as the workspace in which most
work will be done.

The way to implement this completely inside the UIB is to use the
SPW as an include file in the .W that serves as the AW. The SPW's
code needs to be modified so that it can be controlled from the AW.

Follow these guidelines to set up this relationship between two
.W's:

1) Create the AW. Pay attention to what actions will bring up the
SPW.

2) Create the SPW.

3) Delete the ENABLE_UI and DISABLE_UI internal procedures from the
SPW.

4) Comment out the RUNning of these internal procedures along with
the WAIT-FOR statement in the SPW. We no longer need these since
the AW will control when this window should become visible.

5) In the AW's Definition section, add the SPW as an include file.
(e.g. {DEMO-2.W} )

6) The action which should bring up the SPW should simply do the
following:
a) Make the SPW 'un-hidden'. (e.g. ORDER-WIN:HIDDEN = no)
b) Enable the widgets on SPW (if applicable)

7) On the SPW, at least two actions should be available to make it
'invisible':
a) The 'CLOSE' option on the Window's Ventilator.
b) A button which expressly 'Closes' the SPW.

In both cases, we simply make the SPW 'hidden'.
(e.g. ORDER-WIN:HIDDEN = yes)

8) In the AW's DISABLE_UI, add a line to delete the SPW.
(e.g. DELETE WIDGET ORDER-WIN )


Attached below are two .W procedures which demonstrate the above
mentioned concept. DEMO-1.W allows a user to cycle through Customer
records from the SPORTS database. DEMO-2.W is a SPW which browses
the Order records for the customer displayed in the AW. Notice how
the AW controls the SPW and makes it visible when the user requests
to see it. These two procedures are available on the PROGRESS BBS's
Version 7 area in a self-extracting ZIP file called SPW.EXE.

/******************************************************************
****** DEMO-1.W **************************************************
*****************************************************************/
&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v7r9
&ANALYZE-RESUME
/* Connected Databases
SPORTS
*/
&Scoped-define WINDOW-NAME CUST-WIN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS CUST-WIN
/*-----------------------------------------------------------------

File: DEMO-1.W

Description: A UIB .W that shows how to use another UIB .W as
a Static Persistent Window (DEMO-2.W).
This procedure displays Customer records from the
SPORTS database and controls the second window by
manipulating it's HIDDEN attribute.

Input Parameters:
<none>

Output Parameters:
<none>

Author: Gerry Seidl - V7 Language Support Team Leader

Created: 11/10/93 - 8:20 pm

-----------------------------------------------------------------*/
/* This .W file was created with the Progress UIB. */
/*---------------------------------------------------------------*/

/* *************************** Definitions ******************* */

/* Parameters Definitions --- */

/* Local Variable Definitions --- */
{DEMO-2.W} /* Static Persistent Window that browses the orders of
* the customer currently displayed in this window
*/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* *********************** Control Definitions *************** */

/* Define the widget handle for the window */
DEFINE VAR CUST-WIN AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets */
DEFINE BUTTON B-Next
LABEL "Next"
SIZE 9.72 BY 1.17.

DEFINE BUTTON B-Orderwin
LABEL "Orders"
SIZE 9.72 BY 1.17.

DEFINE BUTTON B-Prev
LABEL "Prev"
SIZE 9.72 BY 1.17.


/* ************************ Frame Definitions **************** */

&Scoped-define FRAME-NAME CUST-FRAME
DEFINE FRAME CUST-FRAME
SPORTS.Customer.Cust-Num AT ROW 1.5 COL 17 COLON-ALIGNED
VIEW-AS FILL-IN NATIVE
SIZE 6.86 BY 1
BGCOLOR 15 FGCOLOR 0
SPORTS.Customer.Name AT ROW 3.5 COL 17 COLON-ALIGNED
VIEW-AS FILL-IN NATIVE
SIZE 21.14 BY 1
BGCOLOR 15 FGCOLOR 0
B-Prev AT ROW 5.5 COL 13 HELP
"Find Previous Customer Record"
B-Next AT ROW 5.5 COL 25 HELP
"Find Next Customer Record"
B-Orderwin AT ROW 5.5 COL 42 HELP
"Pop-up the Order Browse Window"
WITH 1 DOWN NO-BOX OVERLAY SIDE-LABELS
AT COL 1 ROW 1
SIZE 54.43 BY 6.08
BGCOLOR 8 FGCOLOR 0 .


/* ************************* Create Window ******************* */

&ANALYZE-SUSPEND _CREATE-WINDOW
CREATE WINDOW CUST-WIN ASSIGN
TITLE = "Customer Window"
COLUMN = 12.43
ROW = 7.67
HEIGHT = 6.08
WIDTH = 55
MAX-HEIGHT = 6.08
MAX-WIDTH = 55
VIRTUAL-HEIGHT = 6.08
VIRTUAL-WIDTH = 55
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = yes
BGCOLOR = 8
FGCOLOR = 0
MESSAGE-AREA = no
SENSITIVE = yes.
&ANALYZE-RESUME


/* *************** Runtime Attributes and UIB Settings ******* */

&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR FRAME CUST-FRAME
UNDERLINE */
/* SETTINGS FOR FILL-IN SPORTS.Customer.Cust-Num IN FRAME CUST-
FRAME
NO-ENABLE */
/* SETTINGS FOR FILL-IN SPORTS.Customer.Name IN FRAME CUST-FRAME
NO-ENABLE */
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME


/* ************************ Control Triggers ***************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL CUST-WIN CUST-WIN
ON WINDOW-CLOSE OF CUST-WIN /* Customer Window */
DO:
DEFINE VARIABLE choice AS LOGICAL.
MESSAGE "Are you sure?" VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO
UPDATE choice.
IF NOT choice THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL B-Next CUST-WIN
ON CHOOSE OF B-Next IN FRAME CUST-FRAME /* Next */
DO:
FIND NEXT customer NO-ERROR.
IF AVAILABLE (customer) THEN
DO:
DISPLAY customer.cust-num customer.name WITH FRAME
CUST-FRAME.
/* If the Order window is already up, re-open the browser
* otherwise, don't do anything with it.
*/
IF ORDER-WIN:VISIBLE = yes THEN
OPEN QUERY BR-ORDER FOR EACH SPORTS.Order
WHERE Order.Cust-Num = Customer.Cust-Num NO-LOCK.
END.
ELSE DO:
MESSAGE "No More Customers to Display".
FIND LAST CUSTOMER NO-ERROR.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL B-Orderwin CUST-WIN
ON CHOOSE OF B-Orderwin IN FRAME CUST-FRAME /* Orders */
DO:
IF ORDER-WIN:VISIBLE = no THEN /* Is Window already up? */
DO:
OPEN QUERY BR-ORDER FOR EACH SPORTS.Order
WHERE Order.Cust-Num = Customer.Cust-Num NO-LOCK.
ASSIGN ORDER-WIN:HIDDEN = no.
ENABLE BR-ORDER B-CLOSE
WITH FRAME ORDER-FRAME IN WINDOW ORDER-WIN.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL B-Prev CUST-WIN
ON CHOOSE OF B-Prev IN FRAME CUST-FRAME /* Prev */
DO:
FIND PREV customer NO-ERROR.
IF AVAILABLE (customer) THEN
DO:
DISPLAY customer.cust-num customer.name WITH FRAME
CUST-FRAME.
/* If the Order window is already up, re-open the browse
* otherwise, don't do anything with it.
*/
IF ORDER-WIN:VISIBLE = yes THEN
OPEN QUERY BR-ORDER FOR EACH SPORTS.Order
WHERE Order.Cust-Num = Customer.Cust-Num NO-LOCK.
END.
ELSE DO:
MESSAGE "No Previous Customers to Display".
FIND FIRST CUSTOMER.
END.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK CUST-WIN


/* *************************** Main Block ******************** */

/* Send messages to alert boxes because there is no message area.
*/
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
SESSION:SYSTEM-ALERT-BOXES = (CURRENT-WINDOW:MESSAGE-AREA = NO).

/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.

/* Find and Display 1st Customer record */
FIND FIRST customer NO-ERROR.
IF AVAILABLE (customer) THEN
DISPLAY customer.cust-num customer.name WITH FRAME CUST-FRAME.

/* Now enable the interface and wait for the exit condition. */
RUN enable_UI.
WAIT-FOR WINDOW-CLOSE OF {&WINDOW-NAME}.
RUN disable_UI.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* ********************** Internal Procedures **************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI CUST-WIN
PROCEDURE disable_UI :
/* ---------------------------------------------------------------
Purpose: DISABLE the User Interface
Parameters: <none>
Notes: Here we clean-up the user-interface by deleting
dynamic widgets we have created and/or hide
frames. This procedure is usually called when
we are ready to "clean-up" after running.
------------------------------------------------------------- */
/* Delete the WINDOW we created */
DELETE WIDGET ORDER-WIN. /* ADDED THIS TO DELETE Order Browse
* Window */
DELETE WIDGET CUST-WIN.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI CUST-WIN
_DEFAULT-ENABLE
PROCEDURE enable_UI :
/* ----------------------------------------------------------------
Purpose: ENABLE the User Interface
Parameters: <none>
Notes: Here we display/view/enable the widgets in the
user-interface. The statements here are based
on the "Default Enabling" section of the widget
Property Sheets.
------------------------------------------------------------- */
ENABLE B-Prev B-Next B-Orderwin
WITH FRAME CUST-FRAME IN WINDOW CUST-WIN.
VIEW CUST-WIN.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&UNDEFINE FRAME-NAME
&UNDEFINE WINDOW-NAME


/******************************************************************
****** DEMO-2.W **************************************************
*****************************************************************/
&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v7r9
&ANALYZE-RESUME
/* Connected Databases
SPORTS
*/
&Scoped-define WINDOW-NAME ORDER-WIN
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS ORDER-WIN
/*-----------------------------------------------------------------

File: DEMO-2.W

Description: A UIB .W which browses the Orders of a Customer
from the SPORTS database which is displayed in
another Window.

This is a Static Persistent Window which serves as
an include file to a .W which controls it. In this
.W, the internal procedures called ENABLE_UI and
DISABLE_UI have been deleted. In its Main Block,
the WAIT-FOR and the RUNning of the deleted
procedures have been commented out. This is
necessary for the other .W to control it.

Input Parameters:
<none>

Output Parameters:
<none>

Author: Gerry Seidl - V7 Language Support Team Leader

Created: 11/10/93 - 8:29 pm

-----------------------------------------------------------------*/
/* This .W file was created with the Progress UIB. */
/*-------------------------------------------------------------- */

/* *************************** Definitions ******************* */

/* Parameters Definitions --- */

/* Local Variable Definitions --- */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* *********************** Control Definitions *************** */

/* Define the widget handle for the window */
DEFINE VAR ORDER-WIN AS WIDGET-HANDLE NO-UNDO.

/* Definitions of the field level widgets */
DEFINE BUTTON B-CLOSE
LABEL "Close":L
SIZE 9.72 BY 1.17.


/* Definitions of the queries */
DEFINE QUERY BR-ORDER FOR SPORTS.Order SCROLLING.

/* Definitions of the browser frames */
DEFINE BROWSE BR-ORDER QUERY BR-ORDER DISPLAY
SPORTS.Order.Order-Date
SPORTS.Order.Order-num
SPORTS.Order.Promise-Date
WITH NO-UNDERLINE SIZE 38 BY 7.5
BGCOLOR 15 FGCOLOR 0 FONT 0.


/* ************************ Frame Definitions **************** */

&Scoped-define FRAME-NAME ORDER-FRAME
DEFINE FRAME ORDER-FRAME
BR-ORDER AT ROW 1.5 COL 2
B-CLOSE AT ROW 9.5 COL 16 HELP
"Close this Window"
WITH 1 DOWN NO-BOX OVERLAY SIDE-LABELS
AT COL 1 ROW 1
SIZE 40 BY 10
BGCOLOR 8 FGCOLOR 0 .


/* ************************* Create Window ******************* */

&ANALYZE-SUSPEND _CREATE-WINDOW
CREATE WINDOW ORDER-WIN ASSIGN
TITLE = "Orders Window"
COLUMN = 69.57
ROW = 7.67
HEIGHT = 10
WIDTH = 40
MAX-HEIGHT = 10
MAX-WIDTH = 40
VIRTUAL-HEIGHT = 10
VIRTUAL-WIDTH = 40
RESIZE = no
SCROLL-BARS = no
STATUS-AREA = yes
BGCOLOR = ?
FGCOLOR = ?
MESSAGE-AREA = no
SENSITIVE = yes.
&ANALYZE-RESUME


/* *************** Runtime Attributes and UIB Settings ******* */

&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR FRAME ORDER-FRAME
UNDERLINE */
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME


/* Definitions of the browser widgets */

&ANALYZE-SUSPEND _BROWSER-BLOCK BR-ORDER
/* QUERY IS NOT OPENED IN enable_UI
OPEN QUERY BR-ORDER FOR EACH SPORTS.Order NO-LOCK.
_BROWSER-BLOCK-END */

/* Browser rebuild information
_TblList = "SPORTS.Order"
_OrdList = ""
_FldNameList[1] = SPORTS.Order.Order-Date
_FldLabelList[1] = ""
_FldFormatList[1] = ""
_FldNameList[2] = SPORTS.Order.Order-num
_FldLabelList[2] = ""
_FldFormatList[2] = ""
_FldNameList[3] = SPORTS.Order.Promise-Date
_FldLabelList[3] = ""
_FldFormatList[3] = ""
_Query =
"DEFINE SHARED QUERY BR-ORDER FOR SPORTS.Order
SCROLLING."
*/ /* BROWSER BR-ORDER */
&ANALYZE-RESUME


/* ************************ Control Triggers ***************** */

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL B-CLOSE ORDER-WIN
ON CHOOSE OF B-CLOSE IN FRAME ORDER-FRAME /* Close */
DO:
ASSIGN ORDER-WIN:HIDDEN = yes. /* 'Hide' this Window. */
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL ORDER-WIN ORDER-WIN
ON WINDOW-CLOSE OF ORDER-WIN /* Orders Window */
DO:
/* We do not want to 'Delete' this window widget, only to
* make it invisible!
*/
APPLY "CHOOSE" TO B-CLOSE IN FRAME ORDER-FRAME.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK ORDER-WIN


/* *************************** Main Block ******************** */

/* Send messages to alert boxes because there is no message area.*/
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
SESSION:SYSTEM-ALERT-BOXES = (CURRENT-WINDOW:MESSAGE-AREA = NO).

/* Best default for GUI applications is... */
PAUSE 0 BEFORE-HIDE.

/* Now enable the interface and wait for the exit condition. */
/*** COMMENT OUT THESE LINES
RUN enable_UI.
WAIT-FOR WINDOW-CLOSE OF {&WINDOW-NAME}.
RUN disable_UI.****/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&UNDEFINE FRAME-NAME
&UNDEFINE WINDOW-NAME

Progress Software Technical Support Note # 12547