ID Number: Q77314
1.00
WINDOWS
Summary:
Calling StrechBlt() from an application developed in Visual Basic
version 1.0 may generate an "Unrecoverable Application Error" (UAE)
message when you use a Windows 256-color video driver and the
following conditions are met:
- The destination object's AutoRedraw property is set to TRUE.
- The destination object's size is an exact multiple of the source
object's size.
This is a problem with StretchBlt(), a Windows 3.0 API function. This
information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
Steps to Reproduce Problem
--------------------------
Note: This error only occurs when using a 256-color video driver.
1. Start Visual Basic, or choose New Project from the File menu.
2. Place two picture controls on Form1. Load a bitmap into Picture1
by assigning the Picture1.Picture property.
3. Place the following code in the GLOBAL.BAS module:
Declare Function StretchBlt% Lib "GDI" (ByVal hDC%, ByVal X%, ByVal Y%,
ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%,
ByVal YSrc%, ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)
Note: The above Declare statement must be on a single line in Visual
Basic.
4. Place the following code in the Form_Click event procedure:
'Initialize source object's (Picture1) size
Form1.ScaleMode = 3
Picture1.BorderStyle = 0
Picture2.BorderStyle = 0
Picture1.Height = 64
Picture1.Width = 64
Picture1.ScaleMode = 3 'StretchBlt uses pixels
Picture2.ScaleMode = 3
Picture2.AutoRedraw = -1 'Turn on Autoredraw for destination
'Set destination object size to a multiple of the source's size
Picture2.Height = 2 * Picture1.Height
Picture2.Width = 2 * Picture1.Width
hdestdc% = picture2.hDC
X% = 0: Y% = 0
nWidth% = picture2.scalewidth
nHeight% = picture2.scaleheight
' Assign information of the source bitmap.
hSrcDC% = picture1.hDC
XSrc% = 0: YSrc% = 0
nsrcwidth% = picture1.scalewidth
nsrcheight% = picture1.scaleheight
' Assign the constant to the Raster operation (dWrop&).
dwRop& = &HCC0020 'to simply copy
'The next two lines should be all one line in Visual Basic:
ret% = StretchBlt(hdestdc%, X%, Y%, nWidth%, nHeight%, hSrcDC%,
XSrc%, YSrc%, nsrcwidth%, nsrcheight%, dwRop&)
Picture2.Picture = Picture2.Image
Note: The StretchBlt function must be placed on a single line when
typed into the Visual Basic code window.
5. Run the program (press F5) and click on the background of Form1. If
you are using a 256-color Windows display driver, a UAE may result.
After the error, you should exit Windows entirely and reboot to avoid
subsequent errors.
This problem only occurs when you have the destination object's size
an exact multiple of the source object's size, the destination objects
AutoRedraw property set to TRUE, and are using a 256-color Windows
video driver.
Additional reference words: 1.00 3.00