Dynamic Object Created in Wrong Window

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 */
 

Attachments

I've not tested it, but try this:

Code:
...
      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:FRAME        = p-frame-wh // Reaffirm the frame attribute if it's changed or not.
               l-wh:WIDTH-PIXELS = l-w.
END.   /* PROGBLOCK */
 
Last edited:
Are the put-shared-value & get-shared-value procedure located in a persistent procedure?

I believe that I can re-produce the issue that you are experiencing.
I think it's how you are persistently storing the last known widget handle in the super procedure that is causing you the issue.

I'm not quite sure what the desired UX result is meant to be.

If is is to present a system message on the most active window, then I would recommend using a publish and subscribe method.

P.S. Available for hire.
 
Last edited:
Thank you James. I am not sure what you mean by "how". The same get and put procedures are internal procedures in a persistent super procedure. They have been in use throughout the system for years, and have been reliable. I will look at that further, though.

Not sure how a "publish and subscribe" method would work in this client/server app.
 
Back
Top