Microsoft KB Archive/264421

= BUG: Application Error Closing Form with Graphics in RichTextBox =

Article ID: 264421

Article Last Modified on 9/27/2004

-

APPLIES TO

 Microsoft Visual Basic 5.0 Professional Edition, when used with:  Microsoft Windows NT 4.0

 Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Windows Millennium Edition</li></ul> </li> Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Windows NT 4.0</li></ul>

 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 NT 4.0</li></ul>

 Microsoft Windows 95</li></ul>

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

<ul> <li>Microsoft Windows Millennium Edition</li></ul> </li> <li>Microsoft Visual Basic 6.0 Enterprise Edition, when used with: <ul> <li>Microsoft Windows NT 4.0</li></ul>

<ul> <li>Microsoft Windows 95</li></ul>

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

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

-

<div class="notice_section">

This article was previously published under Q264421

<div class="symptoms_section">

SYMPTOMS
An Application Error occurs when a Form is closed after multiple graphics have been added to the same line of a RichTextBox control.

This problem does not occur on Microsoft Windows 2000.

<div class="resolution_section">

RESOLUTION
There are two ways to avoid this problem:
 * 1) Because the problem does not occur if the graphics display on different lines within the control, one solution is to keep each graphic on a separate line.
 * 2) If the graphics are cleared from the RichTextBox control prior to closing the Form, the problem does not occur. Call the Clear method of the RichTextBox just prior to unloading the form.

<div class="status_section">

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

<div class="moreinformation_section">

Steps to Reproduce Behavior
Change the following code to point to graphics on your system, otherwise the indicated bitmaps cannot be found: <ol> <li>Create a new Standard EXE project in Visual Basic. Form1 is created by default.</li> <li>From the Project menu, click to select Components, select &quot;Microsoft Rich Textbox Control 6.0,&quot; and then click OK.</li> <li>Add a RichTextBox control to Form1.</li> <li> Paste the following code into the code window of Form1: Private Sub Form_Activate<BR/> ' Choose path and file names for your system RichTextBox1.Width = 10000 RichTextBox1.OLEObjects.Add, , &quot;c:\balloon.bmp&quot; RichTextBox1.SelStart = 1 RichTextBox1.OLEObjects.Add, , &quot;c:\pinstripe.bmp&quot; RichTextBox1.SelStart = 2 End Sub

Private Sub Form_Unload(Cancel As Integer) ' Uncomment the following line to workaround this problem 'RichTextBox1.OLEObjects.Clear End Sub </li> <li>Save the project and press the F5 key to run the program.</li> <li>Close Form1, and note that the Application Error occurs.</li> <li>Restart Visual Basic, select the Recent tab, then select the project you just saved, and click Open.</li> <li>Uncomment the indicated line in the Form_Unload event.</li> <li>Save and run the project, and note that this time when you close Form1, no errors occur.</li></ol>

Additional query words: GPF IPF Invalid Page Fault

Keywords: kbbug kbctrl kbpending KB264421

-

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

© Microsoft Corporation. All rights reserved.