Microsoft KB Archive/135612

= BUG: Form Does Not Release After Being Changed to Modal =

Article ID: 135612

Article Last Modified on 5/7/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

-



This article was previously published under Q135612



SYMPTOMS
When a form is changed from modeless to modal during run time, the form cannot be closed (terminated).

NOTE: In Visual FoxPro 6.0, the Close icon of the control box in the upper right corner of the form allows the form to close.



WORKAROUND
If the form needs to be Modal, set the WindowType to Modal at design time.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
When a form is changed to Modal at run time, it does not release when a Release ThisForm or ThisForm.Release is issued. The only way to close the form is to cancel the program.

Steps to Reproduce Problem
Example One:

 Create a form with the following command buttons:   Command1 with Modal as the caption and the following code for Visual FoxPro 5.0: ThisForm.Visible=.F.     ThisForm.Show(1) ThisForm.Visible=.T.                                Command2 with Release as the caption and ThisForm.Release in the Click event procedure.

NOTE: Ensure that the form's WindowType property is set to 0-Modeless.  Run the form, and verify that the form is Modeless and that the Release button closes the form. Run the form, and click the Modal button. Verify that the form is modal. Click the Release button. The form will not close.</li> Edit the form, and change the WindowType property to 1-Modal.</li> Run the form, verify that the form is modal. Then click the Release button. The form should close.</li></ol>

Example Two: Setting the modal property programatically before the program executes causes the form to behave a little differently. Run the following program with the form's WindowType property set to 1. Click the Release button and verify that although the form is no longer visible, it has not closed. However, defining the form as modeless and then changing it to modal by pressing the Modal command button causes the form to remain on the screen. ******* Start of Example *******

frmModalForm=CREATEOBJECT("ModalForm") frmModalForm.Show READ EVENTS

DEFINE CLASS ModalForm AS Form Top       = 9 Left      = 26 DoCreate  = .T.     Caption    = "Modal Form Test" WindowType = 1 && Change WindowType to 0 to start the form as Modeless

ADD OBJECT Command1 AS CommandButton WITH ; Top    = 145, ; Left   = 31, ; Height = 29, ; Width  = 94, ; Caption = "Modal", ; Name   = "Command1"

ADD OBJECT Command2 AS CommandButton WITH ; Top    = 145, ; Left   = 127, ; Height = 29, ; Width  = 94, ; Caption = "Modeless", ; Name   = "Command2"

ADD OBJECT Command3 AS CommandButton WITH ; Top    = 145, ; Left   = 225, ; Height = 29, ; Width  = 94, ; Caption = "Release", ; Name   = "Command3"

PROCEDURE Command1.Click ThisForm.Visible=.f.         ThisForm.Show(1) ThisForm.Visible=.t.    ENDPROC

PROCEDURE Command2.Click ThisForm.Visible=.f.         ThisForm.Show(0) ThisForm.Visible=.t.    ENDPROC

PROCEDURE Command3.Click ThisForm.Release CLEAR Events ENDPROC

ENDDEFINE

******* End of Example *******

Additional query words: kbvfp600

Keywords: kbbug KB135612

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.