Previous | Index | Next 

[PRB] Output from the Print statement appears slightly different from the original VB6 application

The CodeArchitects.VBLibrary contains a replacement for the Print method exposed by the Form, UserControl, PictureBox, and Printer classes. These methods are implemented in quite different ways.

The Printer.Print method is forwarded to the VBSupportLib.dll – a VB6 DLL that provides printing support to migrated VB.NET - therefore the print output is virtually indistinguishable from the original VB6 output. Conversely, the Print method exposed by the Form, UserControl, and PictureBox classes is simulated and invokes the System.Drawning.Graphics.DrawString method behind the scenes.

For most practical purposes, the VB.NET output mimics the original VB6 closely enough to be usable in real-world applications. However, keep in mind that there are just too many factors that can affect the result and make it differ from the expected one. For example, Windows Forms applications don’t support Windows standard fonts, thus the VB Migration Partner converts them to Arial by default. (You can change this default choice by means of the ReplaceFormFont pragma.) Also, the TextWidth and TextHeight methods in the control support library may return values that slightly differ from their VB6 counterparts.

Finally, we have noticed that the Graphics.DrawString method – that is ultimately used to display the text - tends to offset the output string by a few pixels to the right. If perfect alignment is important, you might need to manually adjust the value of the CurrentX property before emitting the string, for example by means of an InsertStatement pragma:

    Picture1.Cls
    '##InsertStatement Picture1.CurrentX = -120
    Picture1.Print "Test string"

 

Previous | Index | Next