Microsoft KB Archive/184675

= BUG: PictureBox Prints Incorrectly with PrintForm =

Article ID: 184675

Article Last Modified on 11/18/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q184675



SYMPTOMS
When you print a form from the IDE or you use the PrintForm method to print a form containing a PictureBox with its Picture property set to a metafile (.wmf, .emf), the picture in the PictureBox does not print correctly. The picture may appear offset from its original location or may not appear at all.



CAUSE
The greater the Top and Left properties of the PictureBox control are from (0,0), the greater the offset of the actual picture in the printed output. The actual offset of the picture is relative to the size of the form.



RESOLUTION
The following are three different methods you can use to work around this problem:

 Use an Image control rather than a PictureBox control. Set the Picture property of the PictureBox control to a file in another graphics format. In addition to metafiles, the Picture property for a PictureBox also supports the bitmap (.bmp), icon (.ico), GIF, and JPEG file formats. Use another technique to print the form instead of the PrintForm method. The following articles in the Microsoft Knowledge Base discuss techniques you can implement to print your form with Visual Basic:

161299 : HOWTO: Capture and Print the Screen, a Form, or any Window

178076 : HOWTO: Use a PictureBox to Control Orientation Printing a Form





STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default.</li> Draw a PictureBox control in the upper-left corner of Form1. Set the Picture property to any metafile.

NOTE: You can find some metafiles in the Graphics\Metafile of your Visual Basic directory.</li>  Add the following code to the Click event of Form1: PrintForm Picture1.Move 2000 PrintForm

</li> Press the F5 key to run the project.</li> Click Form1.</li></ol>

RESULTS: Notice that the first PrintForm prints the image correctly. However, the second PrintForm, which executes after the Picture control is moved, prints the image incorrectly. Depending on the picture you selected, and the size of the form, the picture may appear off-center or not appear at all.

Additional query words: move left top meta file picture box kbPrinting kbVBp500 kbVBp

Keywords: kbbug KB184675

-

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

© Microsoft Corporation. All rights reserved.