Link to home
Start Free TrialLog in
Avatar of 920gda
920gda

asked on

Printing Forms

I have designed 3 separate forms that include a database. I only need to print part of the data of the three forms. What is the best technique for printing text boxes on this form? I want to keep the apeparance of the text boxes. Can I print frames?  Thanks for any help
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This example uses BitBlt to copy the image of a control (Text1 in this case) to a hidden PictureBox control.  The image of the textbox is then printed using Printer.PaintPicture.


Option Explicit

Private Declare Function BitBlt Lib "gdi32" _
    (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long


Private Sub Command1_Click()
    Dim PrevScale As Long
    PrevScale = Me.ScaleMode
    Me.ScaleMode = 3 'Pixel
    Picture1.AutoRedraw = True
    Picture1.Width = Text1.Width
    Picture1.Height = Text1.Height
    Call BitBlt(Picture1.hDC, 0, 0, Text1.Width, Text1.Height, _
            Me.hDC, Text1.Left, Text1.Top, vbSrcCopy)
    Set Picture1.Picture = Picture1.Image
    Printer.Print ""
    Printer.PaintPicture Picture1.Picture, 100, 100
    Printer.EndDoc
    Picture1.AutoRedraw = False
    Me.ScaleMode = PrevScale
End Sub

Private Sub Form_Load()
    Picture1.Visible = False
    Picture1.BorderStyle = 0 'none
End Sub
Avatar of 920gda
920gda

ASKER

I agree....Just wanted to make sure I was on the right track. Thanks from Macon, Ga.......
No problem.

Lemme know if you need code from Florida...

M
Avatar of 920gda

ASKER

If you have an example code for drawing
boxes with the printer object, I would appreciate.
Printer.Line (x1,y1)-(x2,y2),vbblack,B

This will draw a black box with corners at x1,y1 to x2,y2 (based on your current .Scale).

You can position your text to print inside it with:

Printer.CurrentX = X1 + TinyBitForMargin
Printer.CurrentY = Y1 + TinyBitForMargin
Printer.Print Text1.Text

M
Avatar of 920gda

ASKER

Thanks Mark.....