[ Nevena79 @ 22.11.2008. 13:18 ] @
Pronasla sam na Internetu ovaj kod koji odlicno radi ali nisam bas potpuno vicna da ga i razradim tj shvatim. Moze li neko da mi ga pojasni i napise komentare na srpskom? Mislim da nije puno posla jer sve je gotovo. Code: Imports System.Drawing.Printing Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents btnPrintPreview As System.Windows.Forms.Button Friend WithEvents dlgPrint As System.Windows.Forms.PrintDialog Friend WithEvents dlgPrintPreview As System.Windows.Forms.PrintPreviewDialog Friend WithEvents btnPrintNow As System.Windows.Forms.Button Friend WithEvents btnPrintWithDialog As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1)) Me.btnPrintPreview = New System.Windows.Forms.Button Me.btnPrintWithDialog = New System.Windows.Forms.Button Me.dlgPrint = New System.Windows.Forms.PrintDialog Me.dlgPrintPreview = New System.Windows.Forms.PrintPreviewDialog Me.btnPrintNow = New System.Windows.Forms.Button Me.SuspendLayout() ' 'btnPrintPreview ' Me.btnPrintPreview.Location = New System.Drawing.Point(104, 80) Me.btnPrintPreview.Name = "btnPrintPreview" Me.btnPrintPreview.Size = New System.Drawing.Size(96, 23) Me.btnPrintPreview.TabIndex = 0 Me.btnPrintPreview.Text = "Print Preview" ' 'btnPrintWithDialog ' Me.btnPrintWithDialog.Location = New System.Drawing.Point(104, 120) Me.btnPrintWithDialog.Name = "btnPrintWithDialog" Me.btnPrintWithDialog.Size = New System.Drawing.Size(96, 23) Me.btnPrintWithDialog.TabIndex = 1 Me.btnPrintWithDialog.Text = "Print w/Dialog" ' 'dlgPrintPreview ' Me.dlgPrintPreview.AutoScrollMargin = New System.Drawing.Size(0, 0) Me.dlgPrintPreview.AutoScrollMinSize = New System.Drawing.Size(0, 0) Me.dlgPrintPreview.ClientSize = New System.Drawing.Size(400, 300) Me.dlgPrintPreview.Enabled = True Me.dlgPrintPreview.Icon = CType(resources.GetObject("dlgPrintPreview.Icon"), System.Drawing.Icon) Me.dlgPrintPreview.Location = New System.Drawing.Point(96, 16) Me.dlgPrintPreview.MinimumSize = New System.Drawing.Size(375, 250) Me.dlgPrintPreview.Name = "dlgPrintPreview" Me.dlgPrintPreview.TransparencyKey = System.Drawing.Color.Empty Me.dlgPrintPreview.Visible = False ' 'btnPrintNow ' Me.btnPrintNow.Location = New System.Drawing.Point(104, 160) Me.btnPrintNow.Name = "btnPrintNow" Me.btnPrintNow.Size = New System.Drawing.Size(96, 23) Me.btnPrintNow.TabIndex = 2 Me.btnPrintNow.Text = "Print Now" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.btnPrintNow) Me.Controls.Add(Me.btnPrintWithDialog) Me.Controls.Add(Me.btnPrintPreview) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region ' Display a print preview. Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click ' Make a PrintDocument and attach it to ' the PrintPreview dialog. dlgPrintPreview.Document = PreparePrintDocument() ' Preview. dlgPrintPreview.WindowState = FormWindowState.Maximized dlgPrintPreview.ShowDialog() End Sub ' Print with the print dialog. Private Sub btnPrintWithDialog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintWithDialog.Click ' Make a PrintDocument and attach it to ' the Print dialog. dlgPrint.Document = PreparePrintDocument() ' Display the print dialog. dlgPrint.ShowDialog() End Sub ' Print immediately. Private Sub btnPrintNow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintNow.Click ' Make a PrintDocument object. Dim print_document As PrintDocument = PreparePrintDocument() ' Print immediately. print_document.Print() End Sub ' Make and return a PrintDocument object that's ready ' to print the paragraphs. Private Function PreparePrintDocument() As PrintDocument ' Make the PrintDocument object. Dim print_document As New PrintDocument ' Install the PrintPage event handler. AddHandler print_document.PrintPage, AddressOf Print_PrintPage ' Return the object. Return print_document End Function ' Print the next page. Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) ' Draw a rectangle at the margins. e.Graphics.DrawRectangle(Pens.Black, e.MarginBounds) ' Draw a thick, dashed ellipse. Dim dotted_pen As New Pen(Color.Black, 5) dotted_pen.DashStyle = Drawing2D.DashStyle.Dash e.Graphics.DrawEllipse(dotted_pen, e.MarginBounds) dotted_pen.Dispose() ' Draw a thick diamond. Dim x0 As Integer = e.MarginBounds.X Dim y0 As Integer = e.MarginBounds.Y Dim wid As Integer = e.MarginBounds.Width Dim hgt As Integer = e.MarginBounds.Height Dim pts() As Point = { _ New Point(x0, y0 + hgt \ 2), _ New Point(x0 + wid \ 2, y0), _ New Point(x0 + wid, y0 + hgt \ 2), _ New Point(x0 + wid \ 2, y0 + hgt) _ } e.Graphics.DrawPolygon(New Pen(Color.Black, 5), pts) ' There are no more pages. e.HasMorePages = False End Sub End Class Ovo stampa, i prikazuje printprewiev i omogucava okretanje papira... uglavnom kompletno resenje za stampu. E sad, na papitu ce iscrtati nekakve elipse i to mi u sustini ne treba nego ako bi mi neko pokazao kako da napisem text na odredjenom delu papira, gde se podesava velicina fonta i kako ako ima 2 strane jer ovde ima sve u jednoj. Postavicu i ceo program pa ga mozete skinuti da vidite kako radi. Bila bih vrlo zahvalna na pomoci jer ovo mi cesto treba pa kako ne znam to da koristim uvek komplikujem na drugaciji nacin a ovako je em brze em profesionalnije odradjeno. |