|
■No81156 (グラ さん) に返信 > true にするとプレビュー画面に何も表示されなくなりました。 > どういうことでしょうか?
下記のコードだとどうなりますか?
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Button1.Text = "100%" Me.Button2.Text = "全体" Me.Button3.Text = "再描画"
Me.PrintDocument1.OriginAtMargins = True Me.PrintDocument2.OriginAtMargins = False
Me.PrintPreviewControl1.Document = Me.PrintDocument1 Me.PrintPreviewControl2.Document = Me.PrintDocument2
Me.PrintPreviewControl1.AutoZoom = True Me.PrintPreviewControl2.AutoZoom = True
AddHandler Me.PrintDocument1.PrintPage, AddressOf Me.PrintPage AddHandler Me.PrintDocument2.PrintPage, AddressOf Me.PrintPage End Sub
Private Sub PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Using fnt As New Font("MS Gothic", 18), _ p1 As New Pen(Color.FromArgb(128, Color.Red), 15), _ p2 As New Pen(Color.FromArgb(128, Color.Blue), 15), _ p3 As New Pen(Color.FromArgb(128, Color.Green), 15), _ p4 As New Pen(Color.FromArgb(128, Color.DarkMagenta), 15)
e.Graphics.DrawRectangle(p1, e.PageBounds) e.Graphics.DrawRectangle(p2, e.MarginBounds) e.Graphics.DrawRectangle(p3, Rectangle.Round(e.PageSettings.PrintableArea)) e.Graphics.DrawRectangle(p4, Rectangle.Round(e.Graphics.VisibleClipBounds))
e.Graphics.DrawString(String.Format("IsPreView={0}", _ DirectCast(sender, Printing.PrintDocument).PrintController.IsPreview), _ fnt, Brushes.Black, New Point(0, 0))
e.Graphics.DrawString(String.Format("OriginAtMargins={0}", _ DirectCast(sender, Printing.PrintDocument).OriginAtMargins), _ fnt, Brushes.Black, New Point(0, 30)) _
e.Graphics.DrawString(String.Format("HardMargin={0},{1}", _ e.PageSettings.HardMarginX, e.PageSettings.HardMarginY), _ fnt, Brushes.Black, New Point(0, 60))
e.Graphics.DrawString(String.Format("★Page={0}", e.PageBounds), _ fnt, Brushes.Red, New Point(0, 90))
e.Graphics.DrawString(String.Format("★Margin={0}", e.MarginBounds), _ fnt, Brushes.Blue, New Point(0, 120))
e.Graphics.DrawString(String.Format("★Printable={0}", e.PageSettings.PrintableArea), _ fnt, Brushes.Green, New Point(0, 150))
e.Graphics.DrawString(String.Format("★Clip={0}", e.Graphics.VisibleClipBounds), _ fnt, Brushes.DarkMagenta, New Point(0, 180))
End Using End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.PrintPreviewControl1.Zoom = 1.0 Me.PrintPreviewControl2.Zoom = 1.0 End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Me.PrintPreviewControl1.AutoZoom = True Me.PrintPreviewControl2.AutoZoom = True End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Me.PrintPreviewControl1.InvalidatePreview() Me.PrintPreviewControl2.InvalidatePreview() End Sub End Class
|