Microsoft KB Archive/110989

= FIX: Out of Memory Error When Adding 35-50 Pen Controls =

Article ID: 110989

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q110989



SYMPTOMS
You will receive an "Out of Memory" error message if you attempt to add more than approximately 36 HEdit or approximately 50 BEdit Pen Controls to an individual Form.



WORKAROUND
You can edit in only one control at a time, so use only one of each of the Pen Controls on top of multiple Labels or Picture Box Controls. This will display the result of the edit when you move the focus to another control.

The examples in the More Information section below will demonstrate how to do this for each of the Pen Controls.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been corrected in Visual Basic version 4.0.



MORE INFORMATION
Here are two examples showing how to work around this bug:

Step-by-Step Example One
The following example demonstrates how to use multiple Picture Boxes and one HEdit Control with the DelayRecog = True. This will allow the user to input signatures into a field which will then remain as written, no recognition is performed.

 Start a new project in Visual Basic. Form1 is created by default.  Add the following controls, and set the indicated properties:   Control          Property     Value Picture Box     Name         PictureB Index       0 AutoRedraw  True

Picture Box     Name         PictureB Index       1 AutoRedraw  True

HEdit Control   Name         HEdit1 DelayRecog  True Text

Command Button  Name         Command1 Caption     Clear   Add the following code to the General Declarations section of Form1: 'Enter each of the following Declare statements on one, single line: Declare Function GetDC Lib "USER" (ByVal hWnd As Integer) As Integer Declare Function BitBlt Lib "GDI" (ByVal hDestDC As Integer,     ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer,      ByVal nHeight As Integer, ByVal hSrsDC As Integer,      ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop) As Integer

Const SRCCOPY &H00CC0020& ' Will be used in the call to BitBlt Dim LastPos As Integer    ' Will be used to keep track of the ' last edited field. Dim InkArray(2) As String ' This array will be used to store the ' InkDataString for each of the fields.   Add the following code to the appropriate Control's event procedures: Sub Command1_Click HEdit1.InkDataString = ""    ' Clear the field. End Sub

Sub Form_Load Call PictureB_Click(0)   ' Position the HEdit control over the End Sub                     ' first field.

Sub Picture1_Click (index As Integer) ' Copy the image in the HEdit control to the Picture Box destDC = GetDC(HEdit.hWnd) ' Enter the following three lines as one, single line: dummy% = BitBlt(PictureB(LastPos).HDC, 0, 0,        PictureB(LastPos).ScaleWidth-2, PictureB(LastPos).ScaleHeight-2,         destDC, 1, 1) InkArray(LastPos) = HEdit1.InkDataString ' Save the Ink data for this field. It will be reassigned ' to the HEdit control the next time that field is selected ' and the HEdit control is positioned on top of it. LastPos = index       ' Update LastPos to the current field. HEdit1.Visible = False ' This prevent a flicker when the ' control is moved. HEdit1.Top = PictureB(index).Top    ' Move the HEdit Control on      HEdit1.Left = PictureB(index).Left   ' top of the selected Picture HEdit1.Width = PictureB(index).Width ' box field. HEdit1.Height = PictureB(index).Height HEdit1.InkDataString = InkArray(index) ' Reset the Ink in the ' Hedit Control to that ' stored for this field. HEdit1.Visible = True End Sub 

Step-by-Step Example Two
The following example demonstrates how to use multiple Labels and one HEdit Control with DelayRecog = False. This works using a BEdit control as well. This allows the user to input hand-written characters into a field where those characters will then be recognized and converted into font characters.

 Start a new project in Visual Basic. Form1 is created by default.</li>  Add the following controls, and set the indicated properties: <pre class="fixed_text">  Control         Property      Value ---  Label           Name          LabelF Index        0 Caption

Label          Name          LabelF Index        1 Caption

HEdit Control  Name          HEdit1 DelayRecog   False Text </li>  Add the following code to the General Declarations section of Form1: Dim LastPos As Integer </li>  Add the following code to the appropriate event procedures: Sub Form_Load Call LabelF_Click (0) End Sub

Sub LabelF_Click (index As Integer) LabelF(LastPos).Caption = HEdit.Text   ' Copy the contents of                                              ' the HEdit Control to  the ' Label Control. LastPos = index        ' Update LastPos to the current field. HEdit1.Visible = False ' This prevent a flicker when the ' control is moved. HEdit1.Top = LabelF(index).Top      ' Move the HEdit Control on      HEdit1.Left = LabelF(index).Left     ' top of the selected Picture HEdit1.Width = LabelF(index).Width  ' Box field. HEdit1.Height = LabelF(index).Height HEdit1.Text = LabelF(index).Caption ' Reset the Ink in the HEdit ' Control to that stored for ' this field. HEdit1.Visible = True End Sub </li></ol>

Additional query words: buglist2.00 buglist3.00 2.00 3.00 fixlist4.00

Keywords: kbbug kbfix KB110989

-

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

© Microsoft Corporation. All rights reserved.