XMAS GREETINGS! - NEED HELP PRINTING PAGE AREA

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

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
 
Back
Top