Microsoft KB Archive/167193

= FIX: Buffering Lost when txtbtns Exit Clicked =

Article ID: 167193

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q167193



SYMPTOMS
When an application has more than one form, and buffer mode is other than 1 (unbuffered), the buffering will be lost under certain circumstances. This happens when one or more of the forms uses the DataEnvironment, uses the txtbtns class of the Wizstyle.vcx class library, and the Exit button is clicked.

In Visual FoxPro for Windows versions 3.0 and 3.0b an error message appears when the Revert button is clicked on the surviving form. The message says "Function Requires Row or Table Buffering Mode."

In Visual FoxPro for Windows versions 5.0 and 5.0a there is no message, but the "Revert" button becomes inoperative--a sign that there is nothing in the buffer to revert.



CAUSE
Code in the DESTROY method of the txtbtns class resets buffermode to '1' when the Exit button is clicked. This code is by design to prevent OLE servers from updating general field data during the destroy event. The form is to be released, so no more data changes should be posted to tables involved with that form.



RESOLUTION
If the application does not have tables with general fields that are subject to updating whenever the table is open, the line in the DESTROY method of the txtbtns class that sets buffering to '1' may be commented out.

The line is approximately 30 lines into the txtbtns.DESTROY method. It is as follows: = CursorSetProp("Buffering",1,.ALIAS) &&optimistic table buffering The comment on that line is incorrect.

This change is not supported by Microsoft, and the results of any modification to any of the code in the Wizstyle.vcx library are uncertain because of the numerous dependencies between functions, values, and event methods within the code of those classes. The user makes such modifications at her or his own risk.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This has been corrected in Visual FoxPro 6.0.



Steps to Reproduce Behavior
 Start a new project called Onetwo.pjx. Add a new form named 'one' to the project. Set the name property to "one" (without the quotes). Set the Buffermode property of form one to "2 - optimistic." Open the DataEnvironment for form one and add the Customer table from \Samples\Data. Drag the cust_id, company, and contact fields to the form. Add the Wizstyle.vcx class library from the VFP\Wizards folder to the Forms Designer's toolbar.</li> From the Wizstyle toolbar select txtbtns and add it to the bottom of form one.</li>  Add a single command button captioned "Form Two" to form one. In its Click method place the command: DO FORM two NAME two LINKED </li>  In the LOAD method of form 'one' add the declaration: PUBLIC two to declare a variable named "two." </li> Save the definition of form one into the VFP root directory.</li> Add a second form to the project. Name this form "two." Set its Name property to "two" (without the quotes).</li> Set the Buffermode property of form two to "2 - optimistic."</li> Open the DataEnvironment of form two. Add the customer and the orders table to the DataEnvironment. A parent-child relationship should appear between the two tables.</li> Drag the Cust_ID and Company fields to the form. Add the child (orders) table to the form as a grid. In Visual FoxPro version 5.0 the default Control Source for the grid columns are mapped from the fields of the table. In Visual FoxPro version 3.x, you need to set a columncount, and map the control source of each column.</li> Add the txtbtns class to the bottom of form two.</li> Save form two as Two.scx in the Visual FoxPro root directory.</li> In the debugger (for Visual FoxPro 5.0) or the Debug window (for Visual FoxPro 3.0), add a watch on 'Cursorgetprop("Buffering")' and set a breakpoint on that value (it will break when the value changes). To set the breakpoint double-click on the gray rectangle at the left of the 'Name' value in the Visual FoxPro 5 Watch window, or on the gray bar between the left and right panes of the Visual FoxPro 3 Debug window.</li> Run form one. Click the Edit button, then click the Form Two command button. Form two appears.</li> Click the Exit button on form two.</li></ol>

In the Debugger the running code will BREAK, when the value of Cursorgetprop("Buffering") changes from 3 to 1. In the Trace window the code shows an arrow at the ENDIF statement just after the offending command: =cursorsetprop("buffering",1,.ALIAS) &&optimistic table buffering Visual FoxPro 5.0 and 5.0a disable the Revert button in form one, although the Caption is enabled until it is clicked.

Visual FoxPro 3.0 and 3.0b show the error message "Function Requires Row or Table Buffering Mode" when 'Revert' is clicked on form one.

Keywords: kbbug kbfix kbvfp600fix kbprogramming kbprb KB167193

-

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

© Microsoft Corporation. All rights reserved.