Microsoft KB Archive/156089

= PRB: Closing SDI (Top-Level) Form Does Not Release Menu =

Article ID: 156089

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q156089



SYMPTOMS
If a Top-Level, or single document interface (SDI), form uses a menu, this menu is not automatically released when the form is released.



WORKAROUND
In order for a menu to be released, you must issue the RELEASE MENUS command. If you want the menu to be released when the form is closed, issue the command as follows in the Destroy method of the form: RELEASE MENUS EXTENDED



STATUS
This behavior is by design.



MORE INFORMATION
With Visual FoxPro 5.0 or 6.0, you can create forms that appear outside of (or in lieu of) the FoxPro desktop and that appear in the task list or on the task bar. These forms are called Top-Level, or SDI, forms and require setting the form's ShowWindow property to "2 - As Top-Level Form." You can add menus, toolbars, and child forms to these forms the same way you add them to the Visual FoxPro desktop in this and previous versions of Visual FoxPro.

There is a sample SDI form in the Solution sample application that displays these new capabilities.

Access the Solution sample by clicking Sample Applications from the Help menu in the Visual FoxPro 5.0 or 6.0. This opens the Sample Applications Overview help topic. Start the Solution sample by clicking Run, which is to the right of Solutions Sample under Access.

You can access the SDI form example within the Solution application by clicking Forms to expand the folder tree in the Visual FoxPro Solutions dialog box. Then click "Create an SDI form" and the Run Sample button to run the form. Alternately, you can click the See Code button to display the form in the Form Designer.

You must explicitly release the menu so you can reuse the menu if desired.

Steps to Reproduce Behavior
 Create a form called Test. Set its ShowWindow property to "2 - As Top-Level Form" in the Form Designer.  In the Init method of the form, add the following code: DO TESTMENU.MPR with THIS, .T.                        Create a new menu. Click the Menu button, rather than the Shortcut button. On the Menu menu, click Quick Menu to create a default quick menu. On the View menu, click General Options. In the General Options dialog box, select the Top-Level Form check box, then click OK.</li> On the Menu menu, click Generate and Save the menu as Testmenu. Click the Generate button to generate the default .mpr file.</li> Run the Test form. Notice that the menu appears in the form itself.</li> Close the form. Issue a DISPLAY MEMORY command, and notice that the menu definition remains in memory.</li></ol>

You can place the following code in the form's Destroy method, which causes the menu to be released when the form is closed: RELEASE MENUS (This.Name) EXTENDED NOTE: This technique is explained in more detail in the header of any .mpr file created when you generate a Top-Level menu.

Additional query words: kbdse VFoxWin

Keywords: KB156089

-

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

© Microsoft Corporation. All rights reserved.