Modal forms

Posted by Admin on 12-Sep-2008 10:38

I've created a form that uses WAIT-FOR THIS-OBJECT:ShowDialog() to set itself as a dialog. After I new() the form, I call the method in the form containing the WAIT-FOR. This dialog has ShowInTaskbar=FALSE. If I use the mouse and try to click in the parent form, I am unable to give it focus. This is good.

The parent form has ShowInTaskbar= TRUE. If I click on the taskbar while the modal form is in focus, the parent form shows on top and hides the dialog. If I click on the parent form it doesn't receive focus and I can't get to the dialog.

I'm not using the -debugalert startup parameter (I believe this was an issue in the past with Progress GUI).

I would think this is not normal behavior. For example, in OEA, if I open the project properties dialog, it remains on top whether I click in OEA or on the taskbar.

I don't want to use TopMost for my dialog because it would then show on top of all other apps as well. OEA's dialog do not have that behavior either.

Am I missing a property that would control this or is this expected? (Or has someone already mentioned it?)

Thanks,

JL

All Replies

Posted by Admin on 12-Sep-2008 10:52

The first thing that would come into my mind would be to set the "Parent" property of the Dialog Form to the main form. Did you try that?

Posted by Admin on 12-Sep-2008 10:57

After double checking with MSDN I'd like to recommend the Owner property (not the Parent property).

The ShowDialog property also allows to specify the Owner.

Posted by Admin on 12-Sep-2008 11:06

I tried both parent and owner, separately and together but got the same result.

I'm passing the parent THIS-OBJECT reference to the dialog constructor as INPUT formParent AS Progress.Windows.Form and then setting

THIS-OBJECT:Parent = parentForm.

and/or

THIS-OBJECT:Owner = parentForm.

JL

Posted by Admin on 12-Sep-2008 12:09

Oh I see. The funny thing is, that if I maximize another app on top of that and minimize that app again, the dialog is back on top of the main form.

I need to think about this....

DEFINE VARIABLE f1 AS System.Windows.Forms.Form NO-UNDO .

DEFINE VARIABLE f2 AS System.Windows.Forms.Form NO-UNDO .

SESSION:DEBUG-ALERT = FALSE .

f1 = NEW System.Windows.Forms.Form () .

f2 = NEW System.Windows.Forms.Form () .

f1:Size = NEW System.Drawing.Size(500, 500).

f2:ShowInTaskbar = FALSE.

f1:Shown:SUBSCRIBE ("f1Shown") .

f1:Show() .

WAIT-FOR System.Windows.Forms.Application:Run().

PROCEDURE f1Shown:

DEFINE INPUT PARAMETER o AS System.Object NO-UNDO.

DEFINE INPUT PARAMETER e AS System.Object NO-UNDO.

f2:OWNER = f1.

WAIT-FOR f2:ShowDialog().

System.Windows.Forms.Application:EXIT().

END.

This thread is closed