SoloCodigo

Programación General => C/C++ => C++ Builder => Mensaje iniciado por: scarlet en Miércoles 26 de Mayo de 2004, 18:01

Título: Como Imprimir???
Publicado por: scarlet en Miércoles 26 de Mayo de 2004, 18:01
hola, necesito imprimir solamente el contenido de un memo..
como hacerlo????
acepto sujerencias...
saludos.... ;)
Título: Re: Como Imprimir???
Publicado por: The Black Boy en Miércoles 26 de Mayo de 2004, 18:08
Te refieres a Mandarlo a una impresora??
Título: Re: Como Imprimir???
Publicado por: scarlet en Viernes 28 de Mayo de 2004, 09:43
si, me refiero a mandarlo a la impresora..
un saludo...
Título: Re: Como Imprimir???
Publicado por: _Viktor en Viernes 28 de Mayo de 2004, 21:13
Incluye los siguientes archivos

Código: Text
  1. #include < printers.hpp >
  2. #include < math.h >
  3.  

Pon un componente TPrintDialog, un TMemo y un boton:

Código: Text
  1. void __fastcall TForm1::Button1Click(TObject *Sender)
  2. {
  3. if (PrintDialog1->Execute()) {
  4.  
  5. Printer()->Canvas->Font = Memo1->Font; //Asignamos la fuente de impresion
  6. int lineHeight = abs(MulDiv(Printer()->Canvas->Font->Size,
  7. GetDeviceCaps(Printer()->Handle, LOGPIXELSY), 72)); // determinamos altura de la linea
  8. lineHeight *= 1.4;
  9. int linesPerPage = (Printer()->PageHeight/lineHeight) - 2;
  10. int lineCount = 2; // iniciamos la impresion en la linea 2 para dejar margen (en vez de la 0)
  11.  
  12. Printer()->BeginDoc();
  13. for (int i=0;i < Memo1->Lines->Count;i++) {
  14. if (lineCount++ == linesPerPage) {
  15. lineCount = 2;
  16. Printer()->NewPage();
  17. }
  18. String s = Memo1->Lines->Strings[i];
  19. Printer()->Canvas->TextOut(0, lineCount * lineHeight, s);
  20. }
  21. Printer()->EndDoc();
  22. }
  23. }
  24.  


Haber si te sirve...
Saludos!