Microsoft KB Archive/194885

= PRB: Hiding and Showing Forms in Modal Formset Only Works Once =

Article ID: 194885

Article Last Modified on 5/10/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q194885



SYMPTOMS
The forms in a modal formset can only be hidden and shown once before the active form is all that can be shown.



CAUSE
This is caused when the Hide and Show methods are used to hide and show the forms in the formset.



RESOLUTION
Change the Visible property of the forms directly rather than using the Hide and Show methods. See steps 7 and 16 in the Steps to Reproduce Behavior section below for an example.



STATUS
Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
The Help file for Visual FoxPro 6.0 states the following for the Show method:

The Show method sets a form or form set's Visible property to true (.T.) and makes the form the active object. If a form's Visible property is already set to true (.T.), the Show method makes it the active object.

...

Forms contained within a form set retain their Visible property setting. If a form's Visible property is set to false (.F.), the Show method for the form set does not show the form.

One item to note in the Help file text is that the Show method sets the form's Visible property to true (.T.). Also note that the formset's Show method does not set the Visible property of a form within the formset to true. In the sample code below, the form's Show method is being used, not the formset's.

The Help file for Visual FoxPro 6.0 states the following for the Hide method:

Hides a form, form set, or toolbar by setting the Visible property to false (.F.).

Note that the workaround for this problem is to set the Visible properties of the forms directly rather than through the Show and Hide methods.

Steps to Reproduce Behavior
 Create a new form. From the Form menu pad, choose Create Form Set. Again from the Form menu, choose Add New Form. Position the forms so both can be seen. Add two command buttons to form1.  Set the Caption property on one to Quit.

In the Click event, place the following code: Thisformset.Release </li> Copy the Quit command button and paste it onto the other form.</li>  Go back to form1. Change the Caption on the other command button to "Show Form 2". In the Click event, place the following code: Thisform.Hide Thisformset.Form2.Show * Thisform.Visible=.F.     * Thisformset.Form2.Visible=.T.                        </li> Copy the "Show Form 2" command button and paste it onto form2. Change the caption and code in the Click event to refer to form1 instead of form2.</li> Set the Visible property of form2 to .F.</li> Select the Formset object in the Properties sheet. Set the WindowType property to 1-Modal.</li> Save and run the formset.</li> Click on the Show Form 2 button. Form2 should display.</li> Click on the Show Form 1 button that is on Form2. Form1 should display.</li> Click on the Show Form 2 button that is on Form1. Form2 should not display. This is the problem.</li> Use the Quit button to close the formset.</li> Modify the formset. In the Click event code for the Show Form 1 and Show Form 2 command buttons, comment the Hide and Show commands. Uncomment the commands that set the Visible properties of the forms.</li> Save and run the formset again. Switch between the form. They should be able to be switched between indefinitely.</li></ol>

<div class="references_section">