Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 08-05-2006
Avatar de waltergomez
waltergomez waltergomez is offline
Miembro
 
Registrado: may 2006
Posts: 202
Poder: 21
waltergomez Va por buen camino
Estaba un poco aburrido de mi rutina y aproveche tu problema para hacer algo distinto, esto funciona pero seguro debe haber una forma mejor.
Esta sacado del TForm.Print

procedure TForm1.PrintGridClick(Sender: TObject);
var
bm : TBitmap;
Ofs: Integer;
Bits: HBITMAP;
DIBWidth, DIBHeight: Longint;
PrintWidth, PrintHeight: Longint;
Image: Pointer;
ImageSize, InfoSize: DWORD;
Info: PBitmapInfo;
begin

if GetWindowLong(DBgrid1.Handle, GWL_STYLE) and WS_BORDER <> 0 then
Ofs := -1 // Don't draw form border
else
Ofs := 0; // There is no border

bm := TBitmap.Create;

bm.Width := DBgrid1.Width;
bm.Height := DBgrid1.Height;
bm.Canvas.Lock;
bm.Canvas.Brush := DBgrid1.Brush;
bm.Canvas.FillRect(DBgrid1.ClientRect);
DBgrid1.PaintTo(bm.Canvas.Handle, Ofs, Ofs);
Bits := bm.Handle;
GetDIBSizes(Bits, InfoSize, ImageSize);
Info := AllocMem(InfoSize);

try
Image := AllocMem(ImageSize);
try
GetDIB(Bits, 0, Info^, Image^);
with Info^.bmiHeader do
begin
DIBWidth := biWidth;
DIBHeight := biHeight;
end;
PrintWidth := MulDiv(DIBWidth, Printer.PageHeight, DIBHeight);
if PrintWidth < Printer.PageWidth then
PrintHeight := Printer.PageHeight
else
begin
PrintWidth := Printer.PageWidth;
PrintHeight := MulDiv(DIBHeight, Printer.PageWidth, DIBWidth);
end;
Printer.BeginDoc;
Printer.Canvas.Lock;
StretchDIBits(Printer.Canvas.Handle, 0, 0, PrintWidth, PrintHeight, 0, 0,
DIBWidth, DIBHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY);
Printer.Canvas.Draw(0,0,bm);
Printer.Canvas.Unlock;
Printer.EndDoc;

finally
FreeMem(Image, ImageSize);
end;
finally
FreeMem(Info, InfoSize);
bm.Canvas.Unlock;
bm.Free;
end;
end;


Saludos,
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
¿Imprimir un formulario completo? (problema según la resolución) roedecker Impresión 5 27-06-2006 09:23:09
Imprimir un formulario rafita Varios 2 02-05-2006 10:46:04
Imprimir info de un StringGrid con un QuickRep Pirucho Impresión 5 23-04-2006 18:42:55
Stringgrid a txt//imprimir texto en el form karlita_cb Varios 2 09-12-2004 03:46:47
Imprimir un formulario julucha Impresión 2 12-06-2003 15:43:12


La franja horaria es GMT +2. Ahora son las 03:42:04.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi