|
-
Nov 30th, 1999, 11:28 AM
#1
Thread Starter
Addicted Member
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
-
Dec 1st, 1999, 01:30 AM
#2
Try:
Add a Picturebox to your Form..
Code:
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
[email protected]
[email protected]
[This message has been edited by Aaron Young (edited 12-01-1999).]
-
Dec 1st, 1999, 07:24 AM
#3
Thread Starter
Addicted Member
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
-
Dec 1st, 1999, 10:04 AM
#4
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
[email protected]
[email protected]
-
Dec 1st, 1999, 06:24 PM
#5
Thread Starter
Addicted Member
Thanks Aaron I believe that gone to work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|