In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

RE: Funcion HardCopy()

Foro de Xailer profesional en español
Responder
Angel
Mensajes: 135
Registrado: Mié Mar 21, 2007 1:11 pm

RE: Funcion HardCopy()

Mensaje 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
Bingen Ugaldebere
Mensajes: 1310
Registrado: Mié Sep 26, 2007 7:12 pm

RE: Funcion HardCopy()

Mensaje 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
Angel
Mensajes: 135
Registrado: Mié Mar 21, 2007 1:11 pm

RE: Funcion HardCopy()

Mensaje 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?
Bingen Ugaldebere
Mensajes: 1310
Registrado: Mié Sep 26, 2007 7:12 pm

RE: Funcion HardCopy()

Mensaje 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?
Responder