Microsoft KB Archive/232660

= BUG: A GDI leak occurs when you print a report with a 256-color bitmap and with SET PALETTE OFF in Visual FoxPro for Windows =

Article ID: 232660

Article Last Modified on 2/17/2005

-

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

-



This article was previously published under Q232660



SYMPTOMS
You are printing a report that contains a bitmap or bitmaps using the REPORT FORM command under Windows 95 or Windows 98. If the bitmap resolution is 256-colors or greater and the SET PALETTE setting is OFF, repeated printing of the report results in a leak in GDI resources. If the printing continues for enough iterations (500 to 1000), you might see one or both of the following error messages:

Low Resources

Ninety percent or more of your system resources are in use. To free up system resources, quit any programs that you are not using. If you do not, your computer may stop responding.

[OK]

- or -

Program Error

Printer is not ready.



RESOLUTION
As a workaround, you can try the following:
 * Use the SET PALETTE ON setting within your program. This is the default setting.
 * Perform the printing on Windows NT rather than Windows 95 or Windows 98 computers.
 * Use a bitmap with a resolution of 16-color or monochrome rather than 256-color or 24-bit.



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



Steps to Reproduce Behavior
  Execute the following commands in the Command window to create a 256-color bitmap. The path to MSPaint is only valid for Windows 95 and Windows 98 installations. If your install drive is something other than C:, you must change the drive letter in the RUN command from C: to your actual drive letter: cBmpName = '"'+HOME+'FOX.BMP'+'"' RUN /n C:\PROGRA~1\ACCESS~1\MSPaint &cBmpName  Paint opens with FOX.BMP being edited. Select File, then Save As from the Paint menu. Enter Fox256.bmp as the file name. Select 256-color bitmap from the Save as type drop-down box. Click the Save button and then close Paint. From the Start menu, start the Resource Meter by selecting the Start button, and then selecting Programs/Accessories/System Tools/Resource Meter. If Resource Meter does not appear in the System Tools menu, you can add it through the Control Panel item Add/Remove Programs. Click on the Windows Setup tab in the Add/Remove Programs dialog box, highlight Accessories in the Components list, and click the Details button. In the Accessories dialog box, scroll down in the Components list, and check the check box next to the System Resource Meter. Click OK to close the Accessories dialog, then click OK in the Add/Remove Programs dialog box. The Resource Meter is installed. You might be prompted for your Windows CD ROM. Size and arrange the Visual FoxPro window and the Resource Meter window so you can see both of them at the same time.</li>  Return to FoxPro and run the following code from the Command window: CREATE CURSOR ctemp (f1 c(5)) INSERT INTO ctemp (f1) VALUES ('xxyy') CREATE REPORT testrep FROM ctemp MODIFY REPORT testrep </li> When the Report Designer appears, add a Picture/ActiveX Bound Control to the report Page Header. In the Report Picture dialog box, select the Picture from File option, type the value (home+'fox256.bmp') in the File textbox, and then click OK. Close the Report Designer, and select Yes to save the report.</li>  Run the following code from a program (.PRG) file: SET PALETTE OFF SET MESSAGE TO IF MESSAGEBOX('Have you paused your printer yet?',4,"Tree Saver Alert") = 7 RETURN ENDIF FOR lni = 1 to NUMITERATIONS REPORT FORM testrep TO PRINTER NOCONSOLE IF MOD(lni,10) = 0 SET MESSAGE TO ALLTRIM(STR(lni)) + ' Iterations' ENDIF ENDFOR SET MESSAGE TO                   </li> When the Tree Saver Alert message box appears, pause your printer to prevent the reports from actually printing. Do this by going to the Start menu, selecting Settings and then selecting Printers. Right-click on your default printer, and select Pause Printing. Once you have paused your printer, click Yes in the Tree Saver message box.</li> Monitor the GDI in Resource Meter as the program executes.</li></ol>
 * 1) DEFINE NUMITERATIONS 600

In Resource Meter, GDI resources: % free decreases in increments of one or two percent until completely depleted. The number of iterations is displayed in the Visual FoxPro status bar. The decrease occurs at about one or two percent per 10 iterations of the loop.

If either of the errors displayed in the SYMPTOMS section of this article occurs, set focus to the main Visual FoxPro window and press the ESCAPE key a few times to exit the program.

Once the test has completed, delete the print jobs. Do this by going to the Start menu, selecting Settings and then selecting Printers. Right-click on your default printer, and select Purge Print Documents.

Exiting Visual FoxPro results in some of the GDI resources being made available, but the only way to restore all the resources is to restart Windows 95 or Windows 98.

(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Jim Saunders, Microsoft Corporation.

Keywords: kbbug kbreportwriter kbpending KB232660

-

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

© Microsoft Corporation. All rights reserved.