Microsoft KB Archive/174825

= FIX: Accessing Image Property of PictureBox Diminishes Resources =

Article ID: 174825

Article Last Modified on 9/27/2004

-

APPLIES TO

 Microsoft Visual Basic 5.0 Learning Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows Millennium Edition  Microsoft Visual Basic 5.0 Professional Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li> Microsoft Visual Basic 5.0 Enterprise Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul>

 Microsoft Windows Millennium Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q174825

<div class="symptoms_section">

SYMPTOMS
Using the Image property of a PictureBox control repeatedly diminishes GDI and System resources on Windows 95, Windows 98, or Windows Me.

<div class="resolution_section">

RESOLUTION
Use the BitBlt API function to provide the same functionality as the Image property. The following article in the Microsoft Knowledge Base provides information about using the BitBlt API function:

147810 : HOWTO: Use Windows BitBlt Function in Visual Basic Application

<div class="status_section">

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

<div class="moreinformation_section">

MORE INFORMATION
The following shows you how to create a sample project that demonstrates this bug. The instructions assume that you have the System Resource Meter running so you can see the effect of accessing the Image property. The System Resource Meter is a system tool usually installed in the Accessories program group if you select the System Resource Meter option when you install Windows 95 or Windows 98.

Steps to Reproduce Behavior
<ol> Start a new Standard EXE project in Visual Basic. Form1 is created by default.</li> Add a PictureBox, Command Button, and Label control to Form1.</li> Set the Picture property of the PictureBox control to an appropriate bitmap file.</li> <li> Copy the following code to the Code window of Form1: Option Explicit Private Sub Command1_Click Dim I as Integer For I = 1 to 100 Picture1.Picture = Picture1.Image Label1.Caption = Trim(Str(I)) DoEvents Next I     End Sub

</li> <li>Press the F5 key to run the program. Minimize the Visual Basic IDE so you can see both Form1 and the System Resource meter running. Click Command1 and note that the GDI and System Resources diminish by about 20 percent with the click of the CommandButton.</li></ol>

Additional query words: memory leak resource

Keywords: kbbug kbfix kbvbp600fix kbcontrol KB174825

-

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

© Microsoft Corporation. All rights reserved.