Solved

Printing Forms

Posted on 2000-05-03
7
169 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:920gda
  • 3
  • 3
7 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 50 total points
ID: 2774901
Printing the forms is probably the worst way to do it.

You need to drive the Printer object. You use the .Scale to set your page dimension units and then use .CurrentX/Y to position the cursor. Printer.Print will drop your text at the X/Y you've specified.

Printer.Line and .Circle will give you nice graphics.

You can adjust the .Font properties and such.

None of this is available with Print.Form. Your output will look like screen dumps and be screen/printer resolution dependent - not only that but your text will come out crappy.

M
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2774918
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
0
 

Author Comment

by:920gda
ID: 2774960
I agree....Just wanted to make sure I was on the right track. Thanks from Macon, Ga.......
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:mark2150
ID: 2775069
No problem.

Lemme know if you need code from Florida...

M
0
 

Author Comment

by:920gda
ID: 2777241
If you have an example code for drawing
boxes with the printer object, I would appreciate.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2777266
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
0
 

Author Comment

by:920gda
ID: 2778071
Thanks Mark.....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now