Kbase 15043: How to Overlay NO-ASSIGN Browse Cell with Selection List
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Overlay NO-ASSIGN Browse Cell with Selection List
/*
Here is the sample code that will work against the sports
database.
The browser is defined with the No-Assign option so that
programmer
has control of updates to the database. On F11 of
the terms cell in the browser, a selection-list will
appear over the
x and y coordinates. On mouse-select-dblclick of the
selection-list
the screen-value of the browser is populated with the
screen-value
of what is selected in the selection-list. On row-leave
of the
browser, the record is written out to the database.
*/
&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r2 GUI
&ANALYZE-RESUME
/* Connected Databases
DEMO PROGRESS
*/
&Scoped-define WINDOW-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS C-Win
/*------------------------------------------------------------------------
File:
Description:
Input Parameters:
<none>
Output Parameters:
<none>
Author:
Created:
-----------------------------------------------------------
-------------*/
/* This .W file was created with the Progress UIB.
*/
/*--------------------------------------------------------
--------------*/
/* Create an unnamed pool to store all the widgets created
by this procedure. This is a good default which assures
that this procedure's triggers and internal procedures
will execute in this procedure's storage, and that proper
cleanup will occur on deletion of the procedure. */
CREATE WIDGET-POOL.
/* *************************** Definitions *************
************* */
/* Parameters Definitions ---
*/
/* Local Variable Definitions ---
*/
def var log as logical.
def var wh as widget-handle.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
/* ******************** Preprocessor Definitions ********
************ */
&Scoped-define PROCEDURE-TYPE Window
/* Name of first Frame and/or Browse and/or first Query
*/
&Scoped-define FRAME-NAME DEFAULT-FRAME
&Scoped-define BROWSE-NAME BROWSE-1
/* Internal Tables (found by Frame, Query & Browse Queries)
*/
&Scoped-define INTERNAL-TABLES DEMO.customer
/* Definitions for BROWSE BROWSE-1
*/
&Scoped-define FIELDS-IN-QUERY-BROWSE-1 DEMO.customer.Cust-num DEMO.customer.Name DEMO.customer.Terms
&Scoped-define ENABLED-FIELDS-IN-QUERY-BROWSE-1 DEMO.customer.Name DEMO.customer.Terms
&Scoped-define ENABLED-TABLES-IN-QUERY-BROWSE-1 DEMO.customer
&Scoped-define OPEN-QUERY-BROWSE-1 OPEN QUERY BROWSE-1 FOR EACH DEMO.customer NO-LOCK.
&Scoped-define FIRST-TABLE-IN-QUERY-BROWSE-1 DEMO.customer
&Scoped-define TABLES-IN-QUERY-BROWSE-1 DEMO.customer
/* Definitions for FRAME DEFAULT-FRAME
*/
&Scoped-define OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME {&OPEN-QUERY-BROWSE-1}
/* Standard List Definitions
*/
&Scoped-Define ENABLED-OBJECTS BROWSE-1 EDITOR-1 SELECT-1
&Scoped-Define DISPLAYED-OBJECTS EDITOR-1 SELECT-1
/* Custom List Definitions
*/
/* List-1,List-2,List-3,List-4,List-5,List-6
*/
/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME
/* *********************** Control Definitions *******
*************** */
/* Define the widget handle for the window
*/
DEFINE VAR C-Win AS WIDGET-HANDLE NO-UNDO.
DEFINE VARIABLE EDITOR-1 AS CHARACTER
VIEW-AS EDITOR SCROLLBAR-VERTICAL
SIZE 46 BY 5 NO-UNDO.
DEFINE VARIABLE SELECT-1 AS CHARACTER
VIEW-AS SELECTION-LIST SINGLE SCROLLBAR-VERTICAL
LIST-ITEMS "cash only","certified checks","no checks"
SIZE 18 BY 2.5 NO-UNDO.
/* Query definitions
*/
&ANALYZE-SUSPEND
DEFINE QUERY BROWSE-1 FOR
DEMO.customer SCROLLING.
&ANALYZE-RESUME
/* Browse definitions
*/
DEFINE BROWSE BROWSE-1
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS BROWSE-1 C-Win _STRUCTURED
QUERY BROWSE-1 NO-LOCK DISPLAY
DEMO.customer.Cust-num
DEMO.customer.Name
DEMO.customer.Terms
ENABLE
DEMO.customer.Name
DEMO.customer.Terms
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
WITH NO-ASSIGN SEPARATORS SIZE 58 BY 5.5
TITLE "No-Assign Browser".
/* ************************ Frame Definitions ****
******************* */
DEFINE FRAME DEFAULT-FRAME
BROWSE-1 AT ROW 3 COL 15
EDITOR-1 AT ROW 9 COL 19 NO-LABEL
SELECT-1 AT ROW 14 COL 61 NO-LABEL
WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
SIDE-LABELS NO-UNDERLINE THREE-D
AT COL 1 ROW 1
SIZE 80 BY 16.
/* *********************** Procedure Settings ********
**************** */
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
Type: Window
Allow: Basic,Browse,DB-Fields,Window,Query
*/
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
/* ************************* Create Window ********
****************** */
&ANALYZE-SUSPEND _CREATE-WINDOW
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
CREATE WINDOW C-Win ASSIGN
HIDDEN = YES
TITLE = "<insert window title>"
HEIGHT = 16
WIDTH = 80
MAX-HEIGHT = 16
MAX-WIDTH = 80
VIRTUAL-HEIGHT = 16
VIRTUAL-WIDTH = 80
RESIZE = yes
SCROLL-BARS = no
STATUS-AREA = no
BGCOLOR = ?
FGCOLOR = ?
KEEP-FRAME-Z-ORDER = yes
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
&ANALYZE-RESUME
/* *************** Runtime Attributes and UIB Settings **
************ */
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
/* SETTINGS FOR WINDOW C-Win
VISIBLE,,RUN-PERSISTENT
*/
ASSIGN
EDITOR-1:READ-ONLY IN FRAME DEFAULT-FRAME = TRUE.
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(C-Win)
THEN C-Win:HIDDEN = no.
/* _RUN-TIME-ATTRIBUTES-END */
&ANALYZE-RESUME
/* Setting information for Queries and Browse Widgets fields
*/
&ANALYZE-SUSPEND _QUERY-BLOCK BROWSE BROWSE-1
/* Query rebuild information for BROWSE BROWSE-1
_TblList = "DEMO.customer"
_Options = "NO-LOCK"
_FldNameList[1] = DEMO.customer.Cust-num
_FldNameList[2] > DEMO.customer.Name
"Name" ? ? "character" ? ? ? ? ? ? yes ?
_FldNameList[3] > DEMO.customer.Terms
"Terms" ? ? "character" ? ? ? ? ? ? yes ?
_Query is OPENED
*/ /* BROWSE BROWSE-1 */
&ANALYZE-RESUME
/* ************************ Control Triggers *****
******************* */
&Scoped-define SELF-NAME C-Win
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON END-ERROR OF C-Win /* <insert window title> */
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
/* This case occurs when the user presses the "Esc" key.
In a persistently run window, just ignore this. If
we did not, the
application would exit. */
IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL C-Win C-Win
ON WINDOW-CLOSE OF C-Win /* <insert window title> */
DO:
/* These events will close the window and terminate
the procedure. */
/* (NOTE: this will override any user-defined triggers
previously */
/* defined on the window.)
*/
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN NO-APPLY.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define BROWSE-NAME BROWSE-1
&Scoped-define SELF-NAME BROWSE-1
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL BROWSE-1 C-Win
ON ROW-LEAVE OF BROWSE-1 IN FRAME DEFAULT-FRAME
/* No-Assign Browser */
DO:
if browse-1:current-row-modified then
do:
get current browse-1 exclusive-lock.
if available(customer) then
assign input browse browse-1 customer.name terms.
get current browse-1 no-lock.
end.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME DEMO.customer.Terms
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL DEMO.customer.Terms BROWSE-1 _BROWSE-COLUMN C-Win
ON F11 OF DEMO.customer.Terms IN BROWSE BROWSE-1 /* Terms */
DO:
wh = customer.terms:handle in browse browse-1.
assign select-1:x in frame default-frame =
wh:x + browse-1:x
select-1:y in frame default-frame =
wh:y + browse-1:y.
select-1:visible = true.
apply "entry" to select-1.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&Scoped-define SELF-NAME SELECT-1
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL SELECT-1 C-Win
ON MOUSE-SELECT-DBLCLICK OF SELECT-1 IN FRAME DEFAULT-FRAME
DO:
select-1:visible in frame default-frame = false.
apply "entry" to customer.terms in browse browse-1.
terms:screen-value in browse browse-1 =
select-1:screen-value.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&UNDEFINE SELF-NAME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK C-Win
/* *************************** Main Block ****************
*********** */
/* Set CURRENT-WINDOW: this will parent dialog-boxes and
frames. */
ASSIGN CURRENT-WINDOW = {&WINDOW-NAME}
THIS-PROCEDURE:CURRENT-WINDOW = {&WINDOW-NAME}.
/* The CLOSE event can be used from
inside or outside the procedure to */
/* terminate it.
*/
ON CLOSE OF THIS-PROCEDURE
RUN disable_UI.
/* Best default for GUI applications is...
*/
PAUSE 0 BEFORE-HIDE.
/* Now enable the interface and wait for the exit
condition. */
/* (NOTE: handle ERROR and
END-KEY so cleanup code will always fire. */
MAIN-BLOCK:
DO ON ERROR UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK
ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:
RUN enable_UI.
select-1:visible = false.
log = editor-1:insert-string("Works against
the demo database. The focused
cell shold be terms. Once that is
the focused cell, hit the F11 key and you will
see a selection list pop-up.
Make a selection from the selection-list and
it will populate the browser cell.").
IF NOT THIS-PROCEDURE:PERSISTENT THEN
WAIT-FOR CLOSE OF THIS-PROCEDURE.
END.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
/* ********************** Internal Procedures *
********************** */
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI C-Win _DEFAULT-DISABLE
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 */
IF SESSION:DISPLAY-TYPE eq "GUI":U THEN
DELETE WIDGET C-Win.
IF THIS-PROCEDURE:PERSISTENT THEN
DELETE PROCEDURE THIS-PROCEDURE.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI C-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. In addition, OPEN all queries
associated with each FRAME and BROWSE.
These statements here are based on the "Other
Settings" section of the widget Property Sheets.
------------------------
------------------------------------------------------*/
DISPLAY EDITOR-1 SELECT-1
WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
ENABLE BROWSE-1 EDITOR-1 SELECT-1
WITH FRAME DEFAULT-FRAME IN WINDOW C-Win.
{&OPEN-BROWSERS-IN-QUERY-DEFAULT-FRAME}
VIEW C-Win.
END PROCEDURE.
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
Progress Software Technical Support Note # 15043