![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#2
|
||||
|
||||
|
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, |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
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 |
|