Sharp

Páginas: 2 (430 palabras) Publicado: 10 de noviembre de 2012
Code Snippet

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;using System.Drawing.Printing;



namespace WindowsApplication4

{

public partial class Form1 : Form

{

private Button botonImprimir = new Button();

privatePrintDocument printDocument1 = new PrintDocument();





public Form1()

{

botonImprimir.Text = "Imprimir Formulario";

botonImprimir.Click += newEventHandler(printButton_Click);

printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

this.Controls.Add(botonImprimir);

}void printButton_Click(object sender, EventArgs e)

{

CapturarPantalla();

printDocument1.Print();

}



Bitmap imagen;private void CapturarPantalla()

{

Graphics g = this.CreateGraphics();

Size s = this.Size;

imagen = new Bitmap(s.Width, s.Height, g);Graphics g2 = Graphics.FromImage(imagen);

g2.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);

}



private voidprintDocument1_PrintPage(System.Object sender,

System.Drawing.Printing.PrintPageEventArgs e)

{

e.Graphics.DrawImage(imagen, 0, 0);

}
}
}


ste ejemplo ilustra la formade imprimir una copia del formulario actual.

Ejemplo

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth,int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Sharp
  • MODELO DE SHARPE
  • Sharp tools
  • jude sharp
  • Modelo De Sharpe
  • Gene Sharp
  • ci sharp
  • C sharp

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS