تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
عرض ال PrintPreviewDialog على ملئ الشاشه عند الاستدعاء.
#1
مرحبا شباب،


شغال على كود يطبع الفورم، يقوم باخذ القورم و عرضه في PrintPreviewDialog.

لكن عندما يظهر PrintPreviewDialog يكون بالحجم المصغر Normal و انا اريده ان يكون ملئ الشاشه عندا فتحه maximized.

هذا الكود : 

كود :
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
   PrintForm1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0)
   PrintForm1.Print()

بحثت في الانترنت فوجدت هذا الكود لعمل المطلوب :

كود :
DirectCast(PrintPreviewDialog1, Form).WindowState = FormWindowState.Maximized

لكن انا لا استخدم  PrintPreviewDialog1 بل استدعيه مباشره.
مساعدتكم شباب.
الرد }}}
تم الشكر بواسطة:
#2
مرحبا اخى

افضل تستخدم PrintDocument1

PHP كود :
Public Class Form1

    Private Sub Button1_Click
(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click

        Me
.PrintDocument1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(0000)
 
       Me.PrintPreviewDialog1.Document Me.PrintDocument1
        Me
.PrintPreviewDialog1.WindowState FormWindowState.Maximized
        Me
.PrintPreviewDialog1.ShowDialog()

 
   End Sub

    Private Sub PrintDocument1_PrintPage
(ByVal sender As System.ObjectByVal e As System.Drawing.Printing.PrintPageEventArgsHandles PrintDocument1.PrintPage
        e
.Graphics.DrawImage(GetFormImage, New Point(00))

 
   End Sub

    Private 
Function GetFormImage(Optional ByVal include_borders As Boolean False) As Bitmap
        
' Make the bitmap.
        Dim wid As Integer = Me.Width
        Dim hgt As Integer = Me.Height
        Dim bm As New Bitmap(wid, hgt)

        ' 
Draw the form onto the bitmap.
 
       Me.DrawToBitmap(bm, New Rectangle(00widhgt))

 
       ' If we want the borders, return the bitmap.
        If include_borders Then Return bm

        ' 
Make a smaller bitmap without borders.
 
       wid Me.ClientSize.Width
        hgt 
Me.ClientSize.Height
        Dim bm2 
As New Bitmap(widhgt)

 
       ' Get the offset from the window's corner to its client
        
' area's corner.
 
       Dim pt As New Point(00)
 
       pt PointToScreen(pt)
 
       Dim dx As Integer pt.Me.Left
        Dim dy 
As Integer pt.Me.Top

        
' Copy the part of the original bitmap that we want
        ' 
into the bitmap.
 
       Dim gr As Graphics Graphics.FromImage(bm2)
 
       gr.DrawImage(bm00, New Rectangle(dxdywidhgt), GraphicsUnit.Pixel)
 
       Return bm2
    End 
Function

End Class 
الرد }}}
تم الشكر بواسطة: Rabeea Qbaha , Amir_Alzubidy
#3
(14-09-17, 11:34 AM)أبو نوره كتب : مرحبا اخى

افضل تستخدم PrintDocument1

PHP كود :
Public Class Form1

    Private Sub Button1_Click
(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click

        Me
.PrintDocument1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(0000)
 
       Me.PrintPreviewDialog1.Document Me.PrintDocument1
        Me
.PrintPreviewDialog1.WindowState FormWindowState.Maximized
        Me
.PrintPreviewDialog1.ShowDialog()

 
   End Sub

    Private Sub PrintDocument1_PrintPage
(ByVal sender As System.ObjectByVal e As System.Drawing.Printing.PrintPageEventArgsHandles PrintDocument1.PrintPage
        e
.Graphics.DrawImage(GetFormImage, New Point(00))

 
   End Sub

    Private 
Function GetFormImage(Optional ByVal include_borders As Boolean False) As Bitmap
        
' Make the bitmap.
        Dim wid As Integer = Me.Width
        Dim hgt As Integer = Me.Height
        Dim bm As New Bitmap(wid, hgt)

        ' 
Draw the form onto the bitmap.
 
       Me.DrawToBitmap(bm, New Rectangle(00widhgt))

 
       ' If we want the borders, return the bitmap.
        If include_borders Then Return bm

        ' 
Make a smaller bitmap without borders.
 
       wid Me.ClientSize.Width
        hgt 
Me.ClientSize.Height
        Dim bm2 
As New Bitmap(widhgt)

 
       ' Get the offset from the window's corner to its client
        
' area's corner.
 
       Dim pt As New Point(00)
 
       pt PointToScreen(pt)
 
       Dim dx As Integer pt.Me.Left
        Dim dy 
As Integer pt.Me.Top

        
' Copy the part of the original bitmap that we want
        ' 
into the bitmap.
 
       Dim gr As Graphics Graphics.FromImage(bm2)
 
       gr.DrawImage(bm00, New Rectangle(dxdywidhgt), GraphicsUnit.Pixel)
 
       Return bm2
    End 
Function

End Class 

شكرا كثيرا ابو نوره 
لكن يوجد مشكله صغيره ، وهي انه لا يتم اظهار محتوى الفورم للطباعه. 
يعني عندي عدد من ال textbox يوجد فيها بيانات، هذه ال textbox لا تظهر.
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم