Microsoft KB Archive/262572

= BUG: The formset from a functional conversion closes unexpectedly in Visual FoxPro =

Article ID: 262572

Article Last Modified on 2/12/2007

-

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 7.0 Professional Edition
 * Microsoft Visual FoxPro 8.0 Professional Edition
 * Microsoft Visual FoxPro 9.0 Professional Edition

-



This article was previously published under Q262572



SYMPTOMS
After a functional conversion of a FoxPro 2.x (for either MS-DOS or Microsoft Windows) Screen is performed, the resulting formset closes unexpectedly after printing a report or encountering an error that is handled by the default error handler of Visual FoxPro.



CAUSE
The FoxPro 2.x Screen contained code in the On Window Deactivate section. The Visual FoxPro functional conversion process places this code in the ReadDeactivate event of the resulting formset. Any code or comments in the ReadDeactivate event of the formset cause the form to unload when the Screen loses focus to any of the following items:
 * The Error dialog box of the default Visual FoxPro error handler.
 * The Printing Report spooler dialog box that appears when printing a Visual FoxPro report.
 * The window created by a MODIFY COMMAND or MODIFY MEMO command.
 * Invoking a Visual FoxPro form with a Do FORM command.



RESOLUTION
To avoid this behavior, remove all code and comments from the ReadDeactivate event of the formset. Generally, this code can be placed in the Destroy event of the formset. Test the application to ensure that the code functions properly once it is moved out of the ReadDeactivate event.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
The ReadDeactivate event is specific to a formset and it is used in conjunction with other Read-related events to allow for the conversion of FoxPro 2.x Screens to Visual FoxPro forms. While the behavior is present in the cases described in the &quot;Cause&quot; section of this article, it is not easily reproduced with a formset that is created apart from the functional conversion process.

In FoxPro 2.6
 Using a table in Fox2x format, create a quick report, and then save and close it. Create a new screen. Add a button with the following information:  Two Prompts: (&quot;Print&quot; and &quot;Exit&quot;) variable = m.what2do</li>  VALID PROCEDURE CODE: DO CASE

CASE m.what2do = 1 REPORT FORM NOCONSOLE TO PRINTER PROMPT

CASE m.what2do = 2 CLEAR READ

ENDCASE </li></ul> </li> From the Screen menu, choose Layout.</li> On the Screen Layout window, choose Options, and then choose Code.</li>  In the On Window Activate code section, add the following code: PUSH KEY </li>  In the On Window Deactivate code section, add the following code: POP KEY </li> Save the screen, generate the .spr code, and the run the code.</li> Select to print the report. In the Prompt dialog box, click OK. Note that the screen is still in its READ wait state.</li> Exit the screen.</li></ol>

In Visual FoxPro
<ol> Open the screen created earlier, and perform a functional conversion. After conversion, it may be necessary to overcome the invalid ColorSource bug. Do this as follows: <ol style="list-style-type: lower-alpha;">  USE the screen .scx file as a table.Issue the following commands: REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 0&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 1&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 2&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 3&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 5&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 6&quot;,&quot;ColorSource = 4&quot;) </li>  Issue the following commands: REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 0&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 1&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 2&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 3&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 5&quot;,&quot;ColorSource = 4&quot;) REPLACE ALL properties WITH STRTRAN(properties,&quot;ColorSource = 6&quot;,&quot;ColorSource = 4&quot;) </li></ol> </li> Run the form and then print the report. In Visual FoxPro 8.0 and in Visual FoxPro 9.0, you may have to issue a &quot;_Screen.themes=.f.&quot; command in the Command window to disable theme support so that you can correctly see the command buttons. When the Spooler dialog box closes, the form closes.</li></ol>

Additional query words: disappear

Keywords: kbbug kbcodesnippet kbcontainer kbctrl kbpending kbprint kbxbase KB262572

-

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

© Microsoft Corporation. All rights reserved.