Window and Form focus

Posted by bheavican on 17-Dec-2009 14:12

Openedge 10.2A02

I have 2 forms, 1 window, and 1 dialog box.  If i start my application by running my first form (MainMenu.cls), click on a button which calls my window (Window1.w) persistently.  Then on the persistent window i click on a button to open another form (Form1.cls).  Then on that form I click on a button to launch a dialog-box (Dialog1.w).  When I close the dialog box the focus is returning to my Window1.w instead of Form1.cls.  Am I supposed to have to track which window/form focus is supposed to be going back to?

All Replies

Posted by Admin on 13-Feb-2010 03:25

When I close the dialog box the focus is returning to my Window1.w instead of Form1.cls.  Am I supposed to have to track which window/form focus is supposed to be going back to?

I can still see the behavior on 10.2B.

The issue already start when you open the dialog. The ABL window (your Window1.w) will already be on top of Form1 while the Dialog (dialog1.w) is opened.

You could simply in use THIS-OBJECT:Activate() in Form1.cls - after running non persistently the dialog1.w - to bring the Form back into foreground when the dialog is closed. But still the ABL window would be on top of the form while the dialog is open. This might be o.k. or not.

You cannot parent the dialog to the Shadow Window - which would probably solve the issue in the easiest manor - but it's not supported.

As always with Window and Form interoperability embedded windows seem to be the ultimate solution:

DEFINE VARIABLE hWindow AS HANDLE NO-UNDO.

DEFINE VARIABLE windowContainer1 AS Progress.Windows.WindowContainer NO-UNDO .


windowContainer1 = NEW Progress.Windows.WindowContainer () .

      
windowContainer1:Visible = FALSE .


THIS-OBJECT:Controls:Add (windowContainer1) .


CREATE WINDOW hWindow .


windowContainer1:EmbeddedWindow = hWindow .


VIEW hWindow .


RUN dialog1.w  (hWindow).


FINALLY:


    DELETE OBJECT hWindow .


    DELETE OBJECT windowContainer1 .



END FINALLY.

For that purpose  I create a WindowContainer and an ABL window on the fly (both won't be visible) and pass the handle of that window widget to the dialog procedure, which parents the dialog frame to this window:

MAIN-BLOCK:


DO ON ERROR   UNDO
MAIN-BLOCK, LEAVE MAIN-BLOCK


   ON END-KEY UNDO MAIN-BLOCK, LEAVE MAIN-BLOCK:



  FRAME {&frame-name}:PARENT = phParent .



  RUN enable_UI.



  WAIT-FOR GO OF FRAME {&FRAME-NAME}.


END.


RUN disable_UI.

Surely above code can be beautified and moved to a Form's base class etc.. If you'd prefer a simpler solution to work, I'd report that to tech support.

This thread is closed