FIX: Loading and Unloading a Form Containing MSHFlexGrid Causes GDI Resource Leak (253295)



The information in this article applies to:

  • Microsoft Visual Basic Learning Edition for Windows 5.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

This article was previously published under Q253295

SYMPTOMS

When a form containing an MSHFlexGrid (Msflxgrd.ocx) control is loaded and unloaded, a leak in the Graphics Device Interface (GDI) system resource occurs.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Visual Basic 6.0 Service Pack 4.

To download Visual Basic 6.0 SP4, see the following Microsoft Web site:

MORE INFORMATION

Steps to Reproduce Behavior

  1. On a Microsoft Windows NT 4.0 or Microsoft Windows 2000 computer, start a new standard EXE project with a default form (Form1).
  2. From the Project menu, add another form (Form2).
  3. From the Project menu, select Components, check Microsoft Hierarchical FlexGrid Control 6.0 (SP3) (MSHFLXGD.OCX), and click OK.
  4. Add a CommandButton (Command1) to both Form1 and Form2. Place four MSHflexgrid controls on Form2.
  5. Add the following code to Form1:
    Private Sub Command1_Click()
        Form2.Show
    End Sub
    Private Sub Form_Load()
        Command1.Caption = "Show Form2"
    End Sub
    					
  6. Add the following code to Form2:
    Private Sub Command1_Click()
        Unload Me
    End Sub
    Private Sub Form_Load()
        Command1.Caption = "Unload Me"
    End Sub
    					
  7. Press the F5 key to run the project.
  8. Start Task Manager (CTRL+ALT+DELETE), and select the Processes tab.
  9. Under the View menu, click on Select Columns, and choose GDI Objects.
  10. Click the CommandButtons on Form1 and Form2 to load and unload Form2, and note that for each iteration, there is an increase in one GDI object.

Modification Type:MajorLast Reviewed:5/10/2006
Keywords:kbBug kbCtrl kbDevStudio kbfix kbResource kbVBp600fix KB253295