Página 1 de 1

RE: Funcion HardCopy()

Publicado: Vie Jun 01, 2007 2:36 pm
por Angel
Aquí­ te mando la función "retocada" para que:
- Los bordes de la configuración de la página no corten la imagen.
- La imagen ocupe el total de la pantalla.
Function HardCopy()
LOCAL hBitmap, oBitMap
Application:lBusy := .T.
hBitmap := XA_CaptureBitmap(
GetDesktopWindow(),0,0,Screen:PaperRes()[2],Screen:PaperRes( )[1] )
oBitmap := TBitmap():CreateFromHandle( hBitmap )
Printer:lPreview := .T.
Printer:nPreviewShowMode := smMAXIMIZE
Printer:nPrintQuality := DMRES_HIGH
Printer:cJobTitle := "Impresión de pantalla"
Printer:nOrientation := DMORIENT_LANDSCAPE
Printer:StartDoc()
Printer:oCanvas:nMapMode := mmPIXELS
Printer:StartPage()
Printer:oCanvas:DrawPicture( {
100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
Printer:EndPage()
Printer:EndDoc()
Application:lBusy := .F.
Printer:Preview()
oBitmap:Destroy()
DeleteObject( hBitmap )
Return Nil

RE: Funcion HardCopy()

Publicado: Lun Jun 04, 2007 5:55 pm
por Bingen Ugaldebere
Un último cambio para imprimir un formulario, que es lo que me
interesaba a mi, ahora puedes llamar a Hardcopy() sin parámetros y
tomará todo la pantalla, o si le pasas un objeto tForm te imprimirá ese
form.
Por ejemplo desde cualquier form llamas a HardCopy(Self) se imprime ese
mismo formulario.
Salu2.
Function HardCopy(oForm)
LOCAL hBitmap, oBitMap
Application:lBusy := .T.
hBitmap := If(oForm=Nil,XA_CaptureBitmap(
GetDesktopWindow(),0,0,Screen:PaperRes()[2],Screen:PaperRes( )[1] ),;
XA_CaptureBitmap( oForm:Handle, -10, -25,
oForm:nHeight ,oForm:nWidth) )
oBitmap := TBitmap():CreateFromHandle( hBitmap )
Printer:lPreview := .T.
Printer:nPreviewShowMode := smMAXIMIZE
Printer:nPrintQuality := DMRES_HIGH
Printer:cJobTitle := "Impresión de pantalla"
Printer:nOrientation := DMORIENT_LANDSCAPE
Printer:StartDoc()
Printer:oCanvas:nMapMode := mmPIXELS
Printer:StartPage()
If oForm=Nil
Printer:oCanvas:DrawPicture( {
100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
Else
Printer:oCanvas:DrawPicture( {
100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
Endif
Printer:EndPage()
Printer:EndDoc()
Application:lBusy := .F.
Printer:Preview()
oBitmap:Destroy()
DeleteObject( hBitmap )
Return Nil

RE: Funcion HardCopy()

Publicado: Mar Jun 05, 2007 9:22 am
por Angel
Te comento algo que he visto en la función:
If oForm=Nil
Printer:oCanvas:DrawPicture( {
100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
Else
Printer:oCanvas:DrawPicture( {
100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
Endif
Aquí­ creo que es cuando seleccionas si se imprime un formulario o, en
cambio, se imprime la pantalla completa. Pero ¿las dos lí­neas de código
del IF son totalmente iguales?

RE: Funcion HardCopy()

Publicado: Mar Jun 05, 2007 10:51 am
por Bingen Ugaldebere
Joer cierto, es que estuve haciendo experimentos varios y al final no me
he dado cuenta.
Gracias.
Angel Fernández escribió:
> Te comento algo que he visto en la función:
>
>
> If oForm=Nil
> Printer:oCanvas:DrawPicture( {
> 100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
> Else
> Printer:oCanvas:DrawPicture( {
> 100,100,Printer:PaperRes()[1],Printer:PaperRes()[2] }, oBitmap )
> Endif
>
> Aquí­ creo que es cuando seleccionas si se imprime un formulario o, en
> cambio, se imprime la pantalla completa. Pero ¿las dos lí­neas de código
> del IF son totalmente iguales?