469,622 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,622 developers. It's quick & easy.

XMAS GREETINGS! - NEED HELP PRINTING PAGE AREA

Hi,

I am setting up a orint function that prints the screen area. It is all
working except my screen area spans two print pages hwne viewed using a
print preview dialogue . I am trying to fnd a way to make the print
area fit onto a standard A4 paper print area.

Anyone any idea how I can control this and 'shrink' my current print
document?

Many Thanks

Marc

-------------------------------------------------------------------------------------------
Private Sub PrintScreenToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
PrintScreenToolStripMenuItem.Click
Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument()
CaptureScreen()
PrintPreviewDialog1.Document = PrintDocument1
PrintDocument1.DefaultPageSettings.Landscape = True

PrintDocument1.DefaultPageSettings.Margins.Right = 500
PrintDocument1.DefaultPageSettings.PrintableArea
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
_
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
e.PageSettings.Margins = New
System.Drawing.Printing.Margins(250, 250, 250, 250)
Dim g As Graphics
g = e.Graphics
g.DrawImage(Background, e.MarginBounds.Left,
e.MarginBounds.Top)
g.Dispose()
e.HasMorePages = False
End Sub

Protected Sub CaptureScreen()
Dim hsdc, hmdc As Integer
Dim hbmp, hbmpold As Integer
Dim r As Integer
hsdc = CreateDC("DISPLAY", "", "", "")
hmdc = CreateCompatibleDC(hsdc)
fw = GetDeviceCaps(hsdc, 8)
fh = GetDeviceCaps(hsdc, 10)
hbmp = CreateCompatibleBitmap(hsdc, fw, fh)
hbmpold = SelectObject(hmdc, hbmp)
r = BitBlt(hmdc, 0, 0, fw, fh, hsdc, 0, 0, 13369376)
hbmp = SelectObject(hmdc, hbmpold)
r = DeleteDC(hsdc)
r = DeleteDC(hmdc)
Background = Image.FromHbitmap(New IntPtr(hbmp))
DeleteObject(hbmp)
End Sub

Dec 25 '06 #1
1 1436
http://www.vbcity.com/forums/faq.asp...orms&#TID28614
"Marc" <ma*********@hotmail.comwrote in message
news:11*********************@h40g2000cwb.googlegro ups.com...
Hi,

I am setting up a orint function that prints the screen area. It is all
working except my screen area spans two print pages hwne viewed using a
print preview dialogue . I am trying to fnd a way to make the print
area fit onto a standard A4 paper print area.

Anyone any idea how I can control this and 'shrink' my current print
document?

Many Thanks

Marc

-------------------------------------------------------------------------------------------
Private Sub PrintScreenToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
PrintScreenToolStripMenuItem.Click
Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument()
CaptureScreen()
PrintPreviewDialog1.Document = PrintDocument1
PrintDocument1.DefaultPageSettings.Landscape = True

PrintDocument1.DefaultPageSettings.Margins.Right = 500
PrintDocument1.DefaultPageSettings.PrintableArea
PrintPreviewDialog1.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
_
ByVal e As System.Drawing.Printing.PrintPageEventArgs) _
Handles PrintDocument1.PrintPage
e.PageSettings.Margins = New
System.Drawing.Printing.Margins(250, 250, 250, 250)
Dim g As Graphics
g = e.Graphics
g.DrawImage(Background, e.MarginBounds.Left,
e.MarginBounds.Top)
g.Dispose()
e.HasMorePages = False
End Sub

Protected Sub CaptureScreen()
Dim hsdc, hmdc As Integer
Dim hbmp, hbmpold As Integer
Dim r As Integer
hsdc = CreateDC("DISPLAY", "", "", "")
hmdc = CreateCompatibleDC(hsdc)
fw = GetDeviceCaps(hsdc, 8)
fh = GetDeviceCaps(hsdc, 10)
hbmp = CreateCompatibleBitmap(hsdc, fw, fh)
hbmpold = SelectObject(hmdc, hbmp)
r = BitBlt(hmdc, 0, 0, fw, fh, hsdc, 0, 0, 13369376)
hbmp = SelectObject(hmdc, hbmpold)
r = DeleteDC(hsdc)
r = DeleteDC(hmdc)
Background = Image.FromHbitmap(New IntPtr(hbmp))
DeleteObject(hbmp)
End Sub

Dec 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.