function PrintEnd()
if oPrinter:lMeta
if Empty( oPrinter:cFile )
oPrinter:Preview()
elseif "pdf" $ Lower( oPrinter:cFile )
FWSavePreviewToPDF( oPrinter, If( Lower( cFileExt( oPrinter:cFile ) ) == "pdf", ;
oPrinter:cFile, nil ), oPrinter:lPreview )
endif
else
oPrinter:End()
endif
oPrinter := nil
return nil
//----------------------------------------------------------------------------//
function FWSavePreviewToPDF( oDevice, cPDF, lOpen, nQual ) // oDevice can be oPrinter or oPreview
local cOrient, oPDF
local hWnd , lPreview
DEFAULT nQual := 0 , lPreview := .F.
if oDevice:IsKindOf( "TPREVIEW" )
hWnd := oDevice:oWnd:hWnd
oDevice := oDevice:oDevice
lPreview := .T.
endif
if LoadFreeImage() <= 32
MsgAlert( "freeimage.dll not found" )
return nil
endif
DEFAULT cPDF := cGetFile( "PDF File (*.pdf)|*.pdf|", "Select PDF File to Save", ;
CurDir(), .t. )
if ! Empty( cPDF )
cPDF = cFileSetExt( cPDF, "pdf" )
CursorWait()
cOrient = If( oDevice:nHorzSize() > oDevice:nVertSize(), 'L', 'P' )
oPdf = fwPdf():New( cPdf, cOrient, nQual )
AEval( oDevice:aMeta, { | cMeta |( oPdf:AddMeta( cMeta )) } )
oPdf:Close()
CursorArrow()
DEFAULT lOpen := MsgYesNo( "View " + cPDF + " (Y/N)?" )
if lOpen
ShellExecute( IfNil( hWnd, GetWndDefault() ), "open", cPDF )
endif
else
cPDF := nil
endif
if(!lPreview,oDevice:End(),) //BYTE-ONE 2014
return cPDF
//----------------------------------------------------------------------------//
static function Emf2Jpeg( cEMF , nQual )
local cJpeg := cFileSetExt( cEMF, "jpg" )
local hDC1, hDC, hDib, hDib2, hMem, hBmp, hOldBmp, hEMF
local cBuf, oRect, lRet := .f.
local nFormat
cBuf := MemoRead( cEMF )
oRect := TRect():New( 0, 0, Bin2L( SubStr( cBuf, 21, 4 ) ) / 2, ;
Bin2L( SubStr( cBuf, 17, 4 ) ) / 2 )
cBuf := nil // to release memory
HB_GCAll(.T.)
hEMF := GetEnhMetaFile( cEMF )
hDC1 := GetDC( GetDesktopWindow() )
hDC := CreateCompatibleDC( hDC1 )
hBmp := CreateCompatibleBitmap( hDC1, oRect:nWidth, oRect:nHeight )
hOldBmp := SelectObject( hDC, hBmp )
FillRect( hDC, oRect:aRect, GetStockObject( 0 ) )
PlayEMF( hDC, hEMF, oRect:cRect )
DeleteEnhMetafile( hEMF ) //BYTE-ONE 2014
hDib := DibFromBitmap( hBmp )
cBuf := DibToStr( hDib )
GloBalFree( hDib )
SelectObject( hDC, hOldBmp )
DeleteDC( hDC )
DeleteDC( hDC1 )
DeleteObject( hBmp )
hMem := FI_OpenMemory( cBuf, Len( cBuf ) )
nFormat := FI_GetFileTypeFromMemory( hMem, 0 )
hDib := FI_LoadFromMemory( nFormat, hMem, 0 )
FI_CloseMemory( hMem )
cBuf := nil // to release memory
HB_GCAll(.T.)
hDib2 := FICnv24( hDib )
FIUnload( hDib )
lRet := FISave( 2, hDib2, cJpeg, nQual )
FIUnload( hDib2 )
cBuf := If( lRet, MemoRead( cJpeg ), "" )
FErase( cJpeg )
sysrefresh() //BYTE-ONE 2014
return cBuf
//----------------------------------------------------------------------------//
From: Patrick Mast <patrick@winfakt.com>
Subject: Re: FW Win 2000
Date: Friday, January 05, 2001 2:08 AM
Uwe,
> Big Prob my Fw App crashes with a Gpf under Win 2000
> Any Tip for me ??
My app works great in Win2000.
Have you tried this:
- Code: Select all Expand view
// In the begin of your app:
InterruptRegister( { || ControlGPF() } ) // Setting our own GPF controller
//-----------
function ControlGPF() //SOCS
CLOSE DATA
MsgAlert( "A Windows GPF occured...")
InterruptUnRegister() // We release our GPF controller
Eval( ErrorBlock(), _FWGenError( 5, "Undetermined GPF" ) )
Return nil
//---------
This way maybe you can see what line causes the GPF.
--
Regards,
Patrick Mast
http://www.Patrick.Be.kz
http://www.FiveWin.Be.kz
http://www.Harbour-Project.org
function PrintEnd()
if oPrinter:lMeta
if Empty( oPrinter:cFile )
oPrinter:Preview()
elseif "pdf" $ Lower( oPrinter:cFile )
FWSavePreviewToPDF( oPrinter, oPrinter:cFile, oPrinter:lPreview )
oPrinter:End()
endif
else
oPrinter:End()
endif
oPrinter := nil
return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 44 guests