Microsoft KB Archive/156238

= PRB: Form Not Released from Menu Pad or ON KEY LABEL =

Article ID: 156238

Article Last Modified on 12/3/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 6.0 Professional Edition

-



This article was previously published under Q156238



SYMPTOMS
A form released from a procedure or command called from a menu or an ON KEY LABEL command is not actually released until the command or procedure has completed.



WORKAROUND
Set the Visible property of the form to .F. - False to hide the form until the procedure that releases it has finished executing.



STATUS
This behavior is by design.



MORE INFORMATION
The Keypress event of the form intercepts the keystroke, and the form cannot be released until the procedure or command called by the keystroke has completed.

Steps to Reproduce Behavior
  Run the following code from a .prg: ON KEY LABEL F3 DO Release_It oForm = CREATEOBJECT('form') oForm.Caption = "Press F3 to release form, then F3 to Clear Events" oForm.SHOW READ EVENTS ON KEY LABEL F3

PROCEDURE Release_It oForm.RELEASE =MESSAGEBOX("Though form has been released, _SCREEN.Formcount = " ;        + ALLTR(STR(_SCREEN.FORMCOUNT,1)) + ". Press F3 after OK to " ;         + "return to Command Window." ,0) ON KEY LABEL F3 CLEAR EVENTS ENDPROC  Press the F3 key. The message box indicates the form still exists since the FormCount property of the _SCREEN system variable still returns 1. Click OK then press F3 to return to the Command window.

Modify the Release_It procedure in the above example as follows to demonstrate the workaround. (The form is still not immediately released from memory but setting the Visible property to .F. - False makes it appear released.) PROCEDURE Release_It oForm.Visible = .F.     oForm.RELEASE =MESSAGEBOX("Though form has been released, _SCREEN.Formcount = " ;       + ALLTR(STR(_SCREEN.FORMCOUNT,1)) + ". Press F3 after OK to " ;        + "return to Command Window." ,0) ON KEY LABEL F3 CLEAR EVENTS ENDPROC

Additional query words: kbdse VFoxWin

Keywords: KB156238

-

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

© Microsoft Corporation. All rights reserved.