Or to be more exact: the difference between
WAIT-FOR System.Windows.Forms.Application:Run ( form-object-ref )
and
WAIT-FOR dialog-object-ref:ShowDialog ( parent-form )
Of course I know that ShowDialog is modal and Show is not.
Let me explain the background of this question.
I am doing a lot of projects where I migrate GUI application to GUI for .NET.
It is a nightmare when multiple WAIT-FORs are being used in thos GUI applications. Everybody knows that is bad practice but you could get away with it in GUI. No more in GUI for .NET, but let's put that aside.
Imagine you have the following scenario:
- a login window in GUI for .NET
- a GUI development environment with a traditional WAIT-FOR converted to WAIT-FOR System.Windows.Forms.Application:Run ().
- a test button in the GUI development environment that starts a .NET menu
Next to that you have the following scenario:
- a login window in GUI for .NET
- a .NET main menu
Now normally the .NET login window would have a ShowDialog and the .NET main menu would have a WAIT-FOR System.Windows.Forms.Application:Run ().
In the first scenario you will get the horrible 'Starting a second message loop on a single thread is not a valid operation' message.
That can be solved by starting the .NET menu with ShowDialog.
It looks like ShowDialog in .NET has nothing to do with PERSISTENT or not. In addition, when using ShowDialog the window still behaves like a window, i.e. with minimize and maximize buttons, resizing etc.
So really, why should I not ALWAYS use ShowDialog for the .NET menu?
P.S. According to the help I need to explicitely call the Close() method afterwards when using ShowDialog. OK I can live with that.
I believe Application.Run creates the message queue for .NET objects.
jquerijero wrote:
I believe Application.Run creates the message queue for .NET objects.
meaning?
You will need either
WAIT-FOR Application:Run().
MainForm:Show().
or
WAIT-FOR Application:Run(New MainForm()).
I think WAIT-FOR MainForm:ShowDialog() alone is not enough. The Application:Run() itself (not WAIT-FOR) is the one creating the .NET messaging queue. Remember that there is ABL side and .NET side which have their own messaging queues.