FIX: Form Not Cleared from Memory When Grid Has the Focus (138563)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b

This article was previously published under Q138563

SYMPTOMS

The RELEASE command will not release a form from memory if a grid has the focus when the form is released. The form is cleared off the screen, but _screen.formcount is not decremented, and _screen.activeform.name still shows the name of the form in the Debug window. If another object on the form, such as a text box, has the focus when the form is released, _screen.formcount is decremented, and _screen.activeform.name is cleared.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

  1. Create s program named Main.prg that contains this code:
       SET PROCEDURE TO Main.prg
       ON KEY LABEL F12 CLEAR EVENTS
       ON KEY LABEL F11 SET SYSMENU TO DEFAULT
    
       DO MyMenu.MPR
       READ EVENTS
    
       SET SYSMENU TO DEFAULT
    
       PROCEDURE ClearForms                  && Clear all open forms
           IF _SCREEN.FormCount > 0
                FOR i = _SCREEN.FormCount TO 1 STEP -1
                     _SCREEN.Forms(i).Release
                ENDFOR
           ENDIF
    							
  2. Create a menu named MyMenu.
    1. Add a Form1 prompt that uses this command:
            DO FORM Form1.SCX
      								
    2. Add a Clear Forms prompt that uses this command:
            DO ClearForms
      								
    3. Add an Exit program prompt that uses this command:
            CLEAR EVENTS
      								
    4. Generate and save the menu in the directory where Main.prg is located.
  3. Create a form named Form1.
    1. Add the Customer and Orders tables located in the Vfp\Samples\Data directory to the data environment.
    2. Drag a field from the Customer table onto the form to create a text box.
    3. Drag the Orders table onto the form to create a grid.
    4. Save the form in the directory where Main.prg is located.
  4. Open the Debug window and place _screen.formcount in the left pane.
  5. Run Main.prg.
  6. Click the Form1 menu, and then click the grid to give it the focus. _screen.formcount will equal 1. Multiple instances of Form1 can be run with the same result.
  7. Release Form1 by clicking the Clear Forms menu. Form1 will clear off the screen, but _screen.formcount will still equal 1.
  8. Exit the program, or click the Clear Forms menu again to return _screen.formcount to 0.

Modification Type:MajorLast Reviewed:9/30/2003
Keywords:kbBug kbfix kbvfp500fix KB138563