PDA

Click to See Complete Forum and Search --> : AaronYoung and Party Help!!


ScottF
Nov 30th, 1999, 10:28 AM
I have been trying to use a form as a invoice but when I go and Print it out it does not print the full page. I have try many of a different way's. I have try changing the screen resolution and the lates was given to me by Jaocim


Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Public Const SRCCOPY = &HCC0020
Public Sub PrintFrm(frm As Form, lngWidth As Long, lngHeight As Long)
'Printer.Print 'Importent! The printer object may not have an hDC if it hasn't been used.
Call StretchBlt(Printer.hdc, 0, 0, lngWidth, lngHeight, _
frm.hdc, 0&, 0&, frm.ScaleWidth, frm.ScaleHeight, SRCCOPY)
Printer.Print
Printer.EndDoc
End Sub

Private Sub Command1_Click()
PrintFrm Form1, 8, 11

End Sub
Can you help me

Aaron Young
Dec 1st, 1999, 12:30 AM
Try:
Add a Picturebox to your Form..

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 Const SRCCOPY = &HCC0020

Private Sub Command1_Click()
Dim W As Integer
Dim H As Integer
Dim X As Integer
Dim Y As Integer
Dim oX As Single
Dim oY As Single

oX = Left
oY = Top
W = 400
H = 400
Picture1.Move 0, 0, ScaleWidth, ScaleHeight
For Y = 0 To Int(ScaleHeight / H) + 1
For X = 0 To Int(ScaleWidth / W) + 1
Move ScaleX(-X * W, vbPixels, vbTwips), ScaleY(-Y * H, vbPixels, vbTwips)
DoEvents
BitBlt Picture1.hDC, X * W, Y * H, W, H, hDC, X * W, Y * H, SRCCOPY
Next
Next
Move oX, oY
Printer.PaintPicture Picture1.Image, 0, 0
Printer.EndDoc
End Sub

Private Sub Form_Load()
ScaleMode = vbPixels
With Picture1
.Visible = False
.BorderStyle = vbBSNone
.ScaleMode = vbPixels
.AutoRedraw = True
End With
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net


[This message has been edited by Aaron Young (edited 12-01-1999).]

ScottF
Dec 1st, 1999, 06:24 AM
I made a form place a picturebox on it then added some control in the picturebox.Place a button on the form and paste the code in and try it. It still only print a small picture box in the top left of the page. It does not use the full page

Aaron Young
Dec 1st, 1999, 09:04 AM
Don't place any Controls in the Picturebox, it's used Soley for Copying the Form Image in its Entirity and Transferring it to the Printer.

If your problem is that it's printing the whole Form, just not filling the whole page, use the Extra Width and Height Parameters of the PaintPicture Method to Strech the Picturebox Image to Fit the Whole Page.
NB. doing so may result in any Text being distorted.


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

ScottF
Dec 1st, 1999, 05:24 PM
Thanks Aaron I believe that gone to work.