Bruce Noble
New Member
Developed a procedure to put a system status message at the bottom of any OpenEdge window. This works perfectly most of the time, but in one such window, with the correct parameters passed, the dynamic text object is placed in the window 1 further step up in the stack.
In other words, window "A" (the main screen of the system) runs window "B", which runs the procedure to put a status message at the bottom of the screen. The message, however, appears at the bottom of window "A". Debugging messages have confirmed that frame handle passed is the correct one.
Code below, and attached.
DEF INPUT PARAM p-frame-wh AS HANDLE NO-UNDO.
DEF INPUT PARAM p-text AS CHAR NO-UNDO.
DEF VAR l-proc-wh AS HANDLE NO-UNDO.
DEF VAR l-wh-str AS CHAR NO-UNDO.
DEF VAR l-wh AS HANDLE NO-UNDO.
DEF VAR l-pool AS CHAR NO-UNDO.
DEF VAR l-y AS INT NO-UNDO.
DEF VAR l-x AS INT NO-UNDO.
DEF VAR l-w AS DEC NO-UNDO.
PROGBLOCK:
DO:
ASSIGN l-proc-wh = THIS-PROCEDURE. /* p-frame-wh:INSTANTIATING-PROCEDURE. */
RUN get-shared-value("CUR-STATUS-MSG-HANDLE", OUTPUT l-wh-str).
ASSIGN l-wh = HANDLE(l-wh-str).
ASSIGN l-w = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(p-text, 34).
IF l-w GE p-frame-wh:WIDTH-PIXELS - 10
THEN ASSIGN l-w = p-frame-wh:WIDTH-PIXELS - 10.
IF l-w LE 4
THEN ASSIGN l-w = 4.
/* MESSAGE p-frame-wh:NAME VIEW-AS ALERT-BOX. */
IF NOT VALID-HANDLE(l-wh)
THEN DO:
/* Here, we can't find a valid handle for the status message object. */
/* We will create one, along with it's widget pool. */
ASSIGN l-pool = STRING(l-proc-wh) + "-MSG".
ASSIGN l-y = p-frame-wh:HEIGHT-PIXELS - 23
l-x = 6.
DELETE WIDGET-POOL l-pool NO-ERROR.
CREATE WIDGET-POOL l-pool PERSISTENT NO-ERROR.
CREATE TEXT l-wh IN WIDGET-POOL l-pool
ASSIGN Y = l-y
X = l-x
DATA-TYPE = "CHARACTER"
FORMAT = "X(255)"
FONT = 34
HEIGHT-CHARS = 0.81
WIDTH-PIXELS = l-w
FGCOLOR = 4
BGCOLOR = 15
HIDDEN = FALSE
FRAME = p-frame-wh
SCREEN-VALUE = p-text
VISIBLE = TRUE
SENSITIVE = TRUE.
RUN put-shared-value("CUR-STATUS-MSG-HANDLE", STRING(l-wh)).
END. /* of "IF NOT VALID-HANDLE(l-wh)" */
ELSE ASSIGN l-wh:SCREEN-VALUE = p-text
l-wh:WIDTH-PIXELS = l-w.
END. /* PROGBLOCK */
In other words, window "A" (the main screen of the system) runs window "B", which runs the procedure to put a status message at the bottom of the screen. The message, however, appears at the bottom of window "A". Debugging messages have confirmed that frame handle passed is the correct one.
Code below, and attached.
DEF INPUT PARAM p-frame-wh AS HANDLE NO-UNDO.
DEF INPUT PARAM p-text AS CHAR NO-UNDO.
DEF VAR l-proc-wh AS HANDLE NO-UNDO.
DEF VAR l-wh-str AS CHAR NO-UNDO.
DEF VAR l-wh AS HANDLE NO-UNDO.
DEF VAR l-pool AS CHAR NO-UNDO.
DEF VAR l-y AS INT NO-UNDO.
DEF VAR l-x AS INT NO-UNDO.
DEF VAR l-w AS DEC NO-UNDO.
PROGBLOCK:
DO:
ASSIGN l-proc-wh = THIS-PROCEDURE. /* p-frame-wh:INSTANTIATING-PROCEDURE. */
RUN get-shared-value("CUR-STATUS-MSG-HANDLE", OUTPUT l-wh-str).
ASSIGN l-wh = HANDLE(l-wh-str).
ASSIGN l-w = FONT-TABLE:GET-TEXT-WIDTH-PIXELS(p-text, 34).
IF l-w GE p-frame-wh:WIDTH-PIXELS - 10
THEN ASSIGN l-w = p-frame-wh:WIDTH-PIXELS - 10.
IF l-w LE 4
THEN ASSIGN l-w = 4.
/* MESSAGE p-frame-wh:NAME VIEW-AS ALERT-BOX. */
IF NOT VALID-HANDLE(l-wh)
THEN DO:
/* Here, we can't find a valid handle for the status message object. */
/* We will create one, along with it's widget pool. */
ASSIGN l-pool = STRING(l-proc-wh) + "-MSG".
ASSIGN l-y = p-frame-wh:HEIGHT-PIXELS - 23
l-x = 6.
DELETE WIDGET-POOL l-pool NO-ERROR.
CREATE WIDGET-POOL l-pool PERSISTENT NO-ERROR.
CREATE TEXT l-wh IN WIDGET-POOL l-pool
ASSIGN Y = l-y
X = l-x
DATA-TYPE = "CHARACTER"
FORMAT = "X(255)"
FONT = 34
HEIGHT-CHARS = 0.81
WIDTH-PIXELS = l-w
FGCOLOR = 4
BGCOLOR = 15
HIDDEN = FALSE
FRAME = p-frame-wh
SCREEN-VALUE = p-text
VISIBLE = TRUE
SENSITIVE = TRUE.
RUN put-shared-value("CUR-STATUS-MSG-HANDLE", STRING(l-wh)).
END. /* of "IF NOT VALID-HANDLE(l-wh)" */
ELSE ASSIGN l-wh:SCREEN-VALUE = p-text
l-wh:WIDTH-PIXELS = l-w.
END. /* PROGBLOCK */