MSM-Workstation
Create the First Set of Windows

Go back to the previous page in this sequence
Go back to the start of this chapter
Go back to the first page of this tutorial

One sub-ordinate window, or more?

While testing this sample application, a couple of problems should already have shown themselves:

The reason for the first problem is that the action logic to produce the information in the second window is executed after a "create event". Once a window is created, it will not be re-created, as long as it remains displayed on the screen. If the window is "destroyed" (either by program control, or when the end-user presses the close button (also known as go-away button) on the window itself), a new instance of the window can be created. That instance of the window, of course, will display the information for the cast-member who would be selected when that create event occurs.

In cases where it is desirable that:


the behavior of this example is appropriate, only a precaution needs to be made that prevents the error message shown above.

The essential part of this error message is the substring "M49" in the value of special variable $EC. This error code means "Illegal attempt to set focus", and the error occurred when the end-user clicked on the "first" window to make another selection.

This error can be prevented by setting a property of the second window to a specific value. The property is called "Modal", and the value it needs to have to support this kind of processing is "PARENT".

When the property "MODAL" is set to the value "PARENT", the software generated by MSM-Workstation will recognize that it is not allowed to "return focus" to the first window, and produce an error-beep when the end-user attempts to click on the first window while the second one is still open.

In cases where it is desirable to:

it will be necessary to make a little change to this example to create the desired behavior.

This change involves making the first window "aware" of the fact that it may create multiple instances of the second window. This is done by modifying the call to the macro %%DoWin in the action logic that is executed when a selection is made.

In the initialization code for the first window, a local variable was initialized to a value of 0, and this variable hasn't been used yet. This is the place where that variable comes into play. This variable will count the number of instances of the second window, and can be used as a subscript in arrays to keep track of which settings belong to which instance of the window.

Also, the macro %%DoWin generates code that expects all processing in the called window to complete before control is returned to the originating window. When it is desired to return to the calling window while the called window is still open, the macro %%OpenWin should be used instead of %%DoWin.

The change to the action logic at the selection of a person is:

(Click here to cut and paste this code.)

Note: the name of the variable that counts the number of instances is specified in [square brackets] in the macro call.

With this modification, it will be possible to make any number of selections:

Go on to the next page in this sequence.