leo@lhsistemas.com Posted May 9, 2012 Report Share Posted May 9, 2012 Fiz umas modificações na classe RPREVIEW e na TPRINTER para gerar arquivos para o EXCEL num clique. Porém, uso o FiveWin com xHarbour e adicionei os programas acima para compilarem no xDevStudio. Mas o xDevStudio não está compilando a TPRINTER. Alguem pode me ajudar. Léo. Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 9, 2012 Author Report Share Posted May 9, 2012 Fiz umas modificações na classe RPREVIEW e na TPRINTER para gerar arquivos para o EXCEL num clique. Porém, uso o FiveWin com xHarbour e adicionei os programas acima para compilarem no xDevStudio. Mas o xDevStudio não está compilando a TPRINTER. Alguem pode me ajudar. Léo. Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 9, 2012 Author Report Share Posted May 9, 2012 Pessoal, me ajudem por favor. Quote Link to comment Share on other sites More sharing options...
roberio Posted May 9, 2012 Report Share Posted May 9, 2012 leo "num clique", como assim? desde da versao 2.1 que olho ansioso as novas versoes do FW torcendo que esta solucao seja implementada pela fivetech. obs: sei que tem classe de terceiros para esse proposito. estou curioso, como vc fez isso? Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 9, 2012 Author Report Share Posted May 9, 2012 Rogério, boa tarde. Já tenho pronto e rodando no FW 16, agora, estou migrando para o FW 32 + xHarbour. Copiei a classe original de \FIVEWIN\SOURCE\CLASSE e fiz as devidas modificações para gerar para o Excel conforme já feito no FW 16. Só que as TPRINTER parece não estar compilando as minhas modificações. No RPREVIEW coloquei um botão EXCEL daà gero o arquivo para o MS-EXCEL. Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
Luiz Arruda (ICO) Posted May 9, 2012 Report Share Posted May 9, 2012 Vc. certificou de que realmente está colocando a rPreview e a tPrinter modificadas para serem compiladas no seu projeto ?? troque tb. a Prev32.DLL da pasta do seu projeto.. Luiz Arruda Corumbá-MS ico.corumba@gmail.com | http://www.facebook.com/profile.php?id=100000933378029 FiveWin 9.04 xHarbour PellesC Bcc Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 9, 2012 Author Report Share Posted May 9, 2012 Ico, boa tarde. Sim, coloquei para compilar a RPREVIEW e a PRINTER no xDevStudio para compilar. Fiz sim no PREV32.DLL as mudanças e nada ainda. Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 10, 2012 Author Report Share Posted May 10, 2012 Ico, boa tarde. No PREV32.DLL inseri a imagem da EXCEL no botão. No PRINTER.PRG fiz as mesmas mudanças do FW 16. No RPREVIEW.PRG fiz também as mesmas mudanças do FW 16. Quando dou o Preview do relatório, dá tudo certo. Quando clico no botão EXCEL, dá erro, onde a variável que informa é a declarada e utilizada no PRINTER.PRG, muito estranho. Ajude-me por favor. Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
Luiz Arruda (ICO) Posted May 10, 2012 Report Share Posted May 10, 2012 Seria interessante vc. disponibilizar em DICAS suas alterações com o pessoal do forum, tem gente doida pra ajudar assim como eu mas não temos nem idéia do que vc. alterou nas classes. Além de ajudar outros que possam precisar disso, fora que é idéia poderia ser aproveitada diretamente nas futuras versões do FiveWin com seu nome nela por se tratar de algo útil. Digo isso porque fiz um teste com minha rPreview.prg, fiz um @Say pra mostrar o nome da impressora padrão na barra de botão do preview, coloquei ela("rPreview.prg") na pasta dos meus fontes e compilei junto com a aplicação... deu certo... Outra coisa.. exclua todos os seus Arquivos.OBJid=red> e Arquivos.Cid=red> antes de compilar.. Veja se da certo.. Luiz Arruda Corumbá-MS ico.corumba@gmail.com | http://www.facebook.com/profile.php?id=100000933378029 FiveWin 9.04 xHarbour PellesC Bcc. Editado por - ico on 10/05/2012 14:34:21 Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 10, 2012 Author Report Share Posted May 10, 2012 Ico, boa tarde. Valeu pela dica. Sou novo com FiveWin, mas, com o clipper há muito tempo. Onde posto os fontes mesmo ? Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 10, 2012 Author Report Share Posted May 10, 2012 Ico, boa tarde. No PRINTER para cada comando enviado a impressora crio um arquivo .LHS que contém os @SAY. No RPREVIEW eu criei um arquivo formato excel vazio.xls ai faço a copia dele para o nome que o usuário quer dar ao preview e monto ele de acordo com o script. Segue abaixo a PRINTER.PRG *** INICIO #include "FiveWin.ch" #include "set.ch" #include "struct.ch" #define TA_LEFT 0 #define TA_RIGHT 2 #define TA_CENTER 6 #define ETO_OPAQUE 2 #define ETO_CLIPPED 4 #define HORZSIZE 4 #define VERTSIZE 6 #define HORZRES 8 #define VERTRES 10 #define LOGPIXELSX 88 #define LOGPIXELSY 90 #define MM_TEXT 1 #define MM_LOMETRIC 2 #define MM_HIMETRIC 3 #define MM_LOENGLISH 4 #define MM_HIENGLISH 5 #define MM_TWIPS 6 #define MM_ISOTROPIC 7 #define MM_ANISOTROPIC 8 #define PAD_LEFT 0 #define PAD_RIGHT 1 #define PAD_CENTER 2 // Defines for the oPrn:SetPage(nPage) method (The printer MUST support it) #define DMPAPER_LETTER 1 // Letter 8 1/2 x 11 in #define DMPAPER_LETTERSMALL 2 // Letter Small 8 1/2 x 11 in #define DMPAPER_TABLOID 3 // Tabloid 11 x 17 in #define DMPAPER_LEDGER 4 // Ledger 17 x 11 in #define DMPAPER_LEGAL 5 // Legal 8 1/2 x 14 in #define DMPAPER_STATEMENT 6 // Statement 5 1/2 x 8 1/2 in #define DMPAPER_EXECUTIVE 7 // Executive 7 1/4 x 10 1/2 in #define DMPAPER_A3 8 // A3 297 x 420 mm #define DMPAPER_A4 9 // A4 210 x 297 mm #define DMPAPER_A4SMALL 10 // A4 Small 210 x 297 mm #define DMPAPER_A5 11 // A5 148 x 210 mm #define DMPAPER_B4 12 // B4 250 x 354 #define DMPAPER_B5 13 // B5 182 x 257 mm #define DMPAPER_FOLIO 14 // Folio 8 1/2 x 13 in #define DMPAPER_QUARTO 15 // Quarto 215 x 275 mm #define DMPAPER_10X14 16 // 10x14 in #define DMPAPER_11X17 17 // 11x17 in #define DMPAPER_NOTE 18 // Note 8 1/2 x 11 in #define DMPAPER_ENV_9 19 // Envelope #9 3 7/8 x 8 7/8 #define DMPAPER_ENV_10 20 // Envelope #10 4 1/8 x 9 1/2 #define DMPAPER_ENV_11 21 // Envelope #11 4 1/2 x 10 3/8 #define DMPAPER_ENV_12 22 // Envelope #12 4 \276 x 11 #define DMPAPER_ENV_14 23 // Envelope #14 5 x 11 1/2 #define DMPAPER_CSHEET 24 // C size sheet #define DMPAPER_DSHEET 25 // D size sheet #define DMPAPER_ESHEET 26 // E size sheet #define DMPAPER_ENV_DL 27 // Envelope DL 110 x 220mm #define DMPAPER_ENV_C5 28 // Envelope C5 162 x 229 mm #define DMPAPER_ENV_C3 29 // Envelope C3 324 x 458 mm #define DMPAPER_ENV_C4 30 // Envelope C4 229 x 324 mm #define DMPAPER_ENV_C6 31 // Envelope C6 114 x 162 mm #define DMPAPER_ENV_C65 32 // Envelope C65 114 x 229 mm #define DMPAPER_ENV_B4 33 // Envelope B4 250 x 353 mm #define DMPAPER_ENV_B5 34 // Envelope B5 176 x 250 mm #define DMPAPER_ENV_B6 35 // Envelope B6 176 x 125 mm #define DMPAPER_ENV_ITALY 36 // Envelope 110 x 230 mm #define DMPAPER_ENV_MONARCH 37 // Envelope Monarch 3.875 x 7.5 in #define DMPAPER_ENV_PERSONAL 38 // 6 3/4 Envelope 3 5/8 x 6 1/2 in #define DMPAPER_FANFOLD_US 39 // US Std Fanfold 14 7/8 x 11 in #define DMPAPER_FANFOLD_STD_GERMAN 40 // German Std Fanfold 8 1/2 x 12 in #define DMPAPER_FANFOLD_LGL_GERMAN 41 // German Legal Fanfold 8 1/2 x 13 in // Defines for the oPrn:SetBin(nBin) method (The printer MUST support it) #define DMBIN_FIRST DMBIN_UPPER #define DMBIN_UPPER 1 #define DMBIN_ONLYONE 1 #define DMBIN_LOWER 2 #define DMBIN_MIDDLE 3 #define DMBIN_MANUAL 4 #define DMBIN_ENVELOPE 5 #define DMBIN_ENVMANUAL 6 #define DMBIN_AUTO 7 #define DMBIN_TRACTOR 8 #define DMBIN_SMALLFMT 9 #define DMBIN_LARGEFMT 10 #define DMBIN_LARGECAPACITY 11 #define DMBIN_CASSETTE 14 #define DMBIN_LAST DMBIN_CASSETTE #define DMORIENT_PORTRAIT 1 #define DMORIENT_LANDSCAPE 2 static oPrinter, lTemExcel, nHCMD, nPosLin, nPosCol, nCellRow, nCellCol, nByte, aPosCell //----------------------------------------------------------------------------// CLASS TPrinter Public cFileCMD:="" DATA oFont DATA hDC, hDCOut DATA aMeta DATA cDir, cDocument, cModel DATA nPage, nXOffset, nYOffset, nPad, nOrient DATA lMeta, lStarted, lModified, lPrvModal METHOD New( cDocument, lUser, lMeta, cModel, lModal, lSelection ) CONSTRUCTOR MESSAGE StartPage() METHOD _StartPage() MESSAGE EndPage() METHOD _EndPage() METHOD End() METHOD Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ) METHOD CmSay( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ); INLINE ; ( ::Cmtr2Pix( @nRow, @nCol ),; If( nWidth # Nil, ( ::Cmtr2Pix( 0, @nWidth ), nWidth += ::nYOffset ), nil ),; ::Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ) ) METHOD MmSay( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ); INLINE ; ( ::Mmtr2Pix( @nRow, @nCol ),; If( nWidth # Nil, ( ::Mmtr2Pix( 0, @nWidth ), nWidth += ::nYOffset ), nil ),; ::Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ) ) METHOD InchSay( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ); INLINE ; ( ::Inch2Pix( @nRow, @nCol ),; If( nWidth # Nil, ( ::Inch2Pix( 0, @nWidth ), nWidth += ::nYOffset ), nil ),; ::Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad, lO2A ) ) METHOD SayBitmap( nRow, nCol, cBitmap, nWidth, nHeight, nRaster ) METHOD SayImage( nRow, nCol, oImage, nWidth, nHeight, nRaster, lStretch, nAlphaLevel, nAlign ) METHOD SetPos( nRow, nCol ) INLINE MoveTo( ::hDCOut, nCol, nRow ) METHOD Line( nTop, nLeft, nBottom, nRight, oPen ) INLINE ; MoveTo( ::hDCOut, nLeft, nTop ),; LineTo( ::hDCOut, nRight, nBottom,; If( oPen != nil, oPen:hPen, 0 ) ) METHOD Box( nRow, nCol, nBottom, nRight, oPen ) INLINE ; Rectangle( ::hDCOut, nRow, nCol, nBottom, nRight,; If( oPen != nil, oPen:hPen, 0 ) ) METHOD RoundBox( nRow, nCol, nBottom, nRight, nWidth, nHeight, oPen, nBGColor ) METHOD Arc( nTop, nLeft, nBottom, nRight, nXB, nYB, nXE, nYE, oPen ) INLINE ; Arc( ::hDCOut, nLeft, nTop, nRight, nBottom, nXB, nYB, nXE, nYE, ; If( oPen != nil, oPen:hPen, 0 ) ) METHOD Chord( nTop, nLeft, nBottom, nRight, nXB, nYB, nXE, nYE, oPen ) INLINE ; Chord( ::hDCOut, nLeft, nTop, nRight, nBottom, nXB, nYB, nXE, nYE, ; If( oPen != nil, oPen:hPen, 0 ) ) METHOD Ellipse( nRow, nCol, nBottom, nRight, oPen ) INLINE ; Ellipse( ::hDCOut, nCol, nRow, nRight, nBottom, ; If( oPen != nil, oPen:hPen, 0 ) ) METHOD Pie( nTop, nLeft, nBottom, nRight, nxStartArc, nyStartArc, nxEndArc, nyEndArc, oPen ) INLINE ; Pie( ::hDCOut, nTop, nLeft, nBottom, nRight, nxStartArc, nyStartArc, nxEndArc, nyEndArc, ; If( oPen != nil, oPen:hPen, 0 ) ) METHOD GetPixel( nRow, nCol, nRGBColor ) INLINE ; SetPixel( ::hDCOut, nCol, nRow, nRGBColor ) METHOD SetPixel( nRow, nCol ) INLINE ; SetPixel( ::hDCOut, nCol, nRow ) METHOD Cmtr2Pix( nRow, nCol ) METHOD Mmtr2Pix( nRow, nCol ) METHOD DraftMode( lOnOff ) INLINE (DraftMode( lOnOff ),; ::Rebuild() ) METHOD Inch2Pix( nRow, nCol ) METHOD Pix2Mmtr(nRow, nCol) INLINE ; ( nRow := nRow * 25.4 / ::nLogPixelX() ,; nCol := nCol * 25.4 / ::nLogPixelY() ,; {nRow, nCol} ) METHOD Pix2Inch(nRow, nCol) INLINE ; ( nRow := nRow / ::nLogPixelX() ,; nCol := nCol / ::nLogPixelY() ,; {nRow, nCol} ) METHOD CmRect2Pix(aRect) METHOD nVertRes() INLINE GetDeviceCaps( ::hDC, VERTRES ) METHOD nHorzRes() INLINE GetDeviceCaps( ::hDC, HORZRES ) METHOD nVertSize() INLINE GetDeviceCaps( ::hDC, VERTSIZE ) METHOD nHorzSize() INLINE GetDeviceCaps( ::hDC, HORZSIZE ) METHOD nLogPixelX() INLINE GetDeviceCaps( ::hDC, LOGPIXELSX ) METHOD nLogPixelY() INLINE GetDeviceCaps( ::hDC, LOGPIXELSY ) METHOD SetPixelMode() INLINE SetMapMode( ::hDC, MM_TEXT ) METHOD SetTwipsMode() INLINE SetMapMode( ::hDC, MM_TWIPS ) METHOD SetLoInchMode() INLINE SetMapMode( ::hDC, MM_LOENGLISH ) METHOD SetHiInchMode() INLINE SetMapMode( ::hDC, MM_HIENGLISH ) METHOD SetLoMetricMode() INLINE SetMapMode( ::hDC, MM_LOMETRIC ) METHOD SetHiMetricMode() INLINE SetMapMode( ::hDC, MM_HIMETRIC ) METHOD SetIsotropicMode() INLINE SetMapMode( ::hDC, MM_ISOTROPIC ) METHOD SetAnisotropicMode() INLINE SetMapMode( ::hDC, MM_ANISOTROPIC ) METHOD SetWindowExt( nUnitsWidth, nUnitsHeight ) INLINE ; SetWindowExt( ::hDC, nUnitsWidth, nUnitsHeight ) METHOD SetViewPortExt( nWidth, nHeight ) INLINE ; SetViewPortExt( ::hDC, nWidth, nHeight ) METHOD GetTextWidth( cText, oFont ) INLINE ; GetTextWidth( ::hDC, cText, ::SetFont(oFont):hFont) METHOD GetTextHeight( cText, oFont ) INLINE Abs( ::SetFont(oFont):nHeight ) METHOD Preview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,; RPreview( Self ), ::End() ) MESSAGE FillRect( aRect, oBrush ) METHOD _FillRect( aRect, oBrush ) METHOD ResetDC() INLINE ResetDC( ::hDC ) METHOD GetOrientation() INLINE PrnGetOrientation() METHOD SetLandscape() INLINE ( PrnLandscape( ::hDC ),; ::Rebuild() ) METHOD SetPortrait() INLINE ( PrnPortrait( ::hDC ),; ::Rebuild() ) METHOD SetCopies( nCopies ) INLINE ; ( PrnSetCopies( nCopies ),; ::Rebuild() ) METHOD SetSize( nWidth, nHeight ) INLINE ; ( PrnSetSize( nWidth, nHeight ),; ::Rebuild() ) METHOD SetPage( nPage ) INLINE ; ( PrnSetPage( nPage ),; ::Rebuild() ) METHOD SetBin( nBin ) INLINE ; ( PrnBinSource( nBin ),; ::Rebuild() ) METHOD GetModel() INLINE PrnGetName() METHOD GetDriver() INLINE PrnGetDrive() METHOD GetPort() INLINE PrnGetPort() METHOD GetPhySize() METHOD Setup() INLINE ( PrinterSetup(),; ::Rebuild() ) METHOD Rebuild() METHOD SetFont( oFont ) METHOD CharSay( nRow, nCol, cText ) METHOD CharWidth() METHOD CharHeight() METHOD ImportWMF( cFile ) METHOD ImportRAW( cFile ) METHOD SizeInch2Pix( nHeight, nWidth ) ENDCLASS //----------------------------------------------------------------------------// METHOD New( cDocument, lUser, lMeta, cModel, lModal, lSelection ) CLASS TPrinter local aOffset local cPrinter local oTestExcel DEFAULT cDocument := "FiveWin Report" ,; lUser := .f., lMeta := .f., lModal := .f., lSelection := .f. if lUser ::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() ) if ::hDC != 0 cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort() endif elseif cModel == nil ::hDC := GetPrintDefault( GetActiveWindow() ) if ::hDC != 0 cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort() endif else cPrinter := GetProfString( "windows", "device" , "" ) WriteProfString( "windows", "device", cModel ) SysRefresh() PrinterInit() ::hDC := GetPrintDefault( GetActiveWindow() ) SysRefresh() WriteProfString( "windows", "device", cPrinter ) // PrinterInit() // DeleteDC( ::hDC ) // ::hDC = PrinterDCfromName( cModel ) endif if ::hDC != 0 aOffset = PrnOffset( ::hDC ) ::nXOffset = aOffset[ 1 ] ::nYOffset = aOffset[ 2 ] ::nOrient = ::GetOrientation() elseif ComDlgXErr() != 0 MsgStop( "There are no printers installed!" + CRLF + ; "Please exit this application and install a printer." ) ::nXOffset = 0 ::nYOffset = 0 else ::nXOffset = 0 ::nYOffset = 0 ::nOrient = DMORIENT_PORTRAIT endif ::cDocument = cDocument ::cModel = cModel ::nPage = 0 ::nPad = 0 ::lMeta = lMeta ::lStarted = .F. ::lModified = .F. ::lPrvModal = lModal if !lMeta ::hDcOut = ::hDC else ::aMeta = {} ::cDir = GetEnv( "TEMP" ) if Empty( ::cDir ) ::cDir = GetEnv( "TMP" ) endif if Right( ::cDir, 1 ) == "\" ::cDir = SubStr( ::cDir, 1, Len( ::cDir ) - 1 ) endif if ! Empty( ::cDir ) if ! lIsDir( ::cDir ) ::cDir = GetWinDir() endif else ::cDir := GetWinDir() endif endif // INICIO Leonardo 24-04-2012 // oTestExcel := TOleAuto():New("Excel.Application") If Ole2TxtError() # "S_OK" lTemExcel:= .F. Else lTemExcel:= .T. cFileCMD := cPath_Mod+"\"+StrZero(mNetUse,8)+".LHS" If File(cFileCMD) FErase(cFileCMD) EndIf nHCMD := FCreate(cFileCMD) nByte := 0 aPosCell:={} EndIf // FIM Leonardo 24-04-2012 // return Self //----------------------------------------------------------------------------// METHOD End() CLASS TPrinter if ::hDC != 0 if ! ::lMeta if ::lStarted EndDoc(::hDC) endif else Aeval(::aMeta,{|val| ferase(val) }) ::aMeta := {} ::hDCOut := 0 endif if ::nOrient != nil if ::nOrient == DMORIENT_PORTRAIT ::SetPortrait() else ::SetLandscape() endif endif // PrinterEnd() DeleteDC( ::hDC ) ::hDC := 0 endif if ::oFont != nil ::oFont:End() endif oPrinter := nil return nil //----------------------------------------------------------------------------// METHOD Rebuild() CLASS TPrinter local cPrinter if ::lStarted if ! ::lMeta EndDoc( ::hDC ) else ::hDCOut := 0 endif endif if ::hDC != 0 DeleteDC( ::hDC ) ::hDC := GetPrintDefault( GetActiveWindow() ) ::lStarted := .F. ::lModified := .T. endif if ::hDC != 0 if ! ::lMeta ::hDcOut = ::hDC endif endif return nil //----------------------------------------------------------------------------// METHOD _StartPage() CLASS TPrinter local lSetFixed if ::hDC == 0 return nil endif lSetFixed := Set( _SET_FIXED, .F. ) if ! ::lMeta .and. ! ::lStarted ::lStarted := .T. StartDoc( ::hDC, ::cDocument ) endif ::nPage++ if ::lMeta #ifndef __CLIPPER__ AAdd( ::aMeta, ::cDir + cTempFile( "\", "emf" ) ) ::hDCOut := CreateEnhMetaFile( ::hDC, ATail( ::aMeta ), ::cDocument ) //jlcr #else AAdd( ::aMeta, ::cDir + cTempFile( "\", "wmf" ) ) ::hDCOut := CreateMetaFile( ATail( ::aMeta ) ) #endif else StartPage( ::hDC ) endif Set( _SET_FIXED, lSetFixed ) return nil //----------------------------------------------------------------------------// METHOD _EndPage() CLASS TPrinter if ::hDC = 0 return nil endif if ::lMeta if Len( ::aMeta ) == 0 MsgAlert( "The temporal metafile could not be created",; "Printer object Error" ) else #ifndef __CLIPPER__ DeleteEnhMetaFile( CloseEnhMetaFile( ::hDCOut ) ) #else DeleteMetaFile( CloseMetaFile( ::hDCOut ) ) #endif if ! File( Atail( ::aMeta ) ) MsgAlert("Could not create temporary file: "+Atail(::aMeta)+CRLF+CRLF+; "Please check your free space on your hard drive "+CRLF+; "and the amount of files handles available." ,; "Print preview error" ) endif endif else EndPage( ::hDC ) endif return nil //----------------------------------------------------------------------------// METHOD RoundBox( nRow, nCol, nBottom, nRight, nWidth, nHeight, oPen, nBGColor ) ; CLASS TPrinter local hBrush, hOldBrush local hPen, hOldPen hPen = If( oPen == nil, CreatePen( PS_SOLID, 1, CLR_BLACK ), oPen:hPen ) hOldPen = SelectObject( ::hDCOut, hPen ) if nBGColor != nil hBrush := CreateSolidBrush( nBGColor ) hOldBrush := SelectObject( ::hDCOut, hBrush ) endif RoundRect( ::hDCOut, nRow, nCol, nBottom, nRight, nWidth, nHeight ) if nBGColor # nil SelectObject( ::hDCOut, hOldBrush ) DeleteObject( hBrush ) endif SelectObject( ::hDCOut, hOldPen ) If( oPen == nil, DeleteObject( hPen ), nil ) return nil //----------------------------------------------------------------------------// METHOD Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ) ; CLASS TPrinter local nTemp if ::hDC = 0 return nil endif DEFAULT oFont := ::oFont ,; nBkMode := 1 ,; nPad := ::nPad if oFont != nil oFont:Activate( ::hDCOut ) endif SetbkMode( ::hDCOut, nBkMode ) // 1,2 transparent or Opaque if nClrText != nil SetTextColor( ::hDCOut, nClrText ) endif if Empty( nWidth ) do case case nPad == PAD_RIGHT nCol := Max( 0, nCol - ::GetTextWidth( cText, oFont ) ) case nPad == PAD_CENTER nCol := Max( 0, nCol - ( ::GetTextWidth( cText, oFont ) / 2 ) ) endcase SetTextAlign( ::hDCOut, TA_LEFT ) TextOut( ::hDCOut, nRow, nCol, cText ) else do case case nPad == PAD_RIGHT nTemp := nCol + nWidth SetTextAlign( ::hDCOut, TA_RIGHT ) case nPad == PAD_CENTER nTemp := nCol + ( nWidth / 2 ) SetTextAlign( ::hDCOut, TA_CENTER ) otherwise nTemp := nCol SetTextAlign( ::hDCOut, TA_LEFT ) endcase ExtTextOut( ::hDCOut, nRow, nTemp,; { nRow, nCol, nRow + oFont:nHeight * 1.5, nCol + nWidth },; cText, ETO_CLIPPED ) endif if oFont != nil oFont:DeActivate( ::hDCOut ) endif // INICIO Leonardo // If lTemExcel nCol := If(nCol==0,1,nCol) If nCellRow = NIL nCellRow := nRow nCellCol := 1 nPosLin := nRow nPosCol := 1 EndIf If nCellRow != nRow nCellRow := nRow nCellCol := 1 nPosLin += 1 nPosCol := 1 EndIf If nCellCol != nCol nCellCol := nCol nPosCol += 1 EndIf If nRow > 0 .and. nCol > 0 cString := "Say("+Alltrim(Str(nPosLin))+","+; Alltrim(Str(nPosCol))+","+; "'"+StrTran(cText,"'","`")+"'"+",'Arial',10)" + Chr(13) + Chr(10) nByte := FWrite(nHCMD,cString,Len(cString)) nCellCol++ EndIf EndIf // Fim Leonardo // return nil //----------------------------------------------------------------------------// METHOD SayBitmap( nRow, nCol, xBitmap, nWidth, nHeight, nRaster ) CLASS TPrinter local hDib, aBmpPal, hBitmap, hPalette if ::hDC = 0 return nil endif if ( ValType( xBitmap ) == "N" ) .or. ! File( xBitmap ) aBmpPal = PalBmpLoad( xBitmap ) hBitmap = aBmpPal[ 1 ] hPalette = aBmpPal[ 2 ] hDib = DibFromBitmap( hBitmap, hPalette ) PalBmpFree( hBitmap, hPalette ) else hDib = DibRead( xBitmap ) endif if hDib == 0 return nil endif if ! ::lMeta hPalette = DibPalette( hDib ) endif DibDraw( ::hDCOut, hDib, hPalette, nRow, nCol,; nWidth, nHeight, nRaster ) GlobalFree( hDib ) if ! ::lMeta DeleteObject( hPalette ) endif return nil //----------------------------------------------------------------------------// METHOD SayImage( nRow, nCol, oImage, nWidth, nHeight, nRaster, lStretch, nAlphaLevel, nAlign ) CLASS TPrinter local hDib, hPalBmp, hPal, nRatio, n, cImageBuf, lCreated := .f. local hBmp, x, y DEFAULT nWidth := 0, nHeight := 0, lStretch := .t., nAlphaLevel := 255, nAlign := 1 // center if ::hDC = 0 return nil endif if ValType( oImage ) == 'C' if File( oImage ) oImage := TImage():Define( , oImage ) lCreated := .t. else cImageBuf := oImage oImage := TImage():Define() oImage:LoadFromMemory( cImageBuf ) lCreated := .t. endif endif do case case ValType( oImage ) == "O" hDib = DibFromBitmap( oImage:hBitmap, oImage:hPalette ) otherwise hDib = 0 endcase if hDib = 0 return nil endif if ! ::lMeta hPal := DibPalette( hDib ) endif x := nWidth; y := nHeight // try to keep aspect ratio if only one size is passed in. if nWidth == 0 .and. nHeight > 0 .and. ( n := oImage:nHeight() ) > 0 nRatio := oImage:nWidth() / n x := int( nHeight * nRatio ) elseif nWidth > 0 .and. nHeight == 0 .and. ( n := oImage:nWidth() ) > 0 nRatio := oImage:nHeight() / n y := int( nWidth * nRatio ) elseif nWidth > 0 .and. nHeight > 0 .and. ! lStretch if ( nWidth / oImage:nWidth() ) < ( nHeight / oImage:nHeight() ) x := nWidth; y := oImage:nHeight() * ( nWidth / oImage:nWidth() ) else y := nHeight; x := oImage:nWidth() * ( nHeight / oImage:nHeight() ) endif if x < nWidth if lAnd( nAlign, 1 ) // DT_CENTER = 1 nCol += Int( ( nWidth - x ) / 2 ) elseif lAnd( nAlign, 2 ) // DT_RIGHT = 2 nCol += ( nWidth - x ) endif endif if y < nWidth if lAnd( nAlign, 4 ) // DT_VCENTER = 4 nRow += Int( ( nHeight - y ) / 2 ) elseif lAnd( nAlign, 8 ) // DT_BOTTOM = 8 nRow += ( nHeight - y ) endif endif endif if oImage:HasAlpha() hBmp := ResizeBmp( oImage:hBitmap, x, y ) // ABPaint( ::hDCOut, nRow, nCol, hBmp, nAlphaLevel ) ABPaint( ::hDCOut, nCol, nRow, hBmp, nAlphaLevel ) DeleteObject( hBmp ) else DibDraw( ::hDCOut, hDib, hPal, nRow, nCol, x, y, nRaster ) endif GlobalFree( hDib ) if ! ::lMeta DeleteObject( hPal ) endif if lCreated oImage:End() endif return nil //----------------------------------------------------------------------------// METHOD _FillRect( aCols, oBrush ) CLASS TPrinter if ::hDC = 0 return nil endif FillRect( ::hDCOut, aCols, oBrush:hBrush ) return nil //----------------------------------------------------------------------------// METHOD Cmtr2Pix( nRow, nCol ) CLASS TPrinter if ValType( ::nYoffset ) == "U" ::nYoffset := 0 endif if ValType( ::nXOffset ) == "U" ::nXoffset := 0 endif nRow := Max( 0, ( nRow * 10 * ::nVertRes() / ::nVertSize() ) - ::nYoffset ) nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset ) return { nRow, nCol } //----------------------------------------------------------------------------// METHOD Mmtr2Pix( nRow, nCol ) CLASS TPrinter if ValType( ::nYoffset ) == "U" ::nYoffset := 0 endif if ValType( ::nXOffset ) == "U" ::nXoffset := 0 endif nRow := Max( 0, ( nRow * ::nVertRes() / ::nVertSize() ) - ::nYoffset ) nCol := Max( 0, ( nCol * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset ) return { nRow, nCol } //----------------------------------------------------------------------------// METHOD CmRect2Pix(aRect) CLASS TPrinter local aTmp[ 4 ] aTmp[ 1 ] = Max( 0, ( aRect[1] * 10 * ::nVertRes() / ::nVertSize() ) - ::nYoffset ) aTmp[ 2 ] = Max( 0, ( aRect[2] * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset ) aTmp[ 3 ] = Max( 0, ( aRect[3] * 10 * ::nVertRes() / ::nVertSize() ) - ::nYoffset ) aTmp[ 4 ] = Max( 0, ( aRect[4] * 10 * ::nHorzRes() / ::nHorzSize() ) - ::nXoffset ) return aTmp //----------------------------------------------------------------------------// METHOD Inch2Pix( nRow, nCol ) CLASS TPrinter nRow = Max( 0, ( nRow * ::nVertRes() / (::nVertSize() / 25.4 ))-::nYoffset ) nCol = Max( 0, ( nCol * ::nHorzRes() / (::nHorzSize() / 25.4 ))-::nXoffset ) return { nRow, nCol } //----------------------------------------------------------------------------// METHOD GetPhySize() CLASS TPrinter local aData := PrnGetSize( ::hDC ) local nWidth, nHeight nWidth := aData[ 1 ] / ::nLogPixelX() * 25.4 nHeight := aData[ 2 ] / ::nLogPixelY() * 25.4 return { nWidth, nHeight } //----------------------------------------------------------------------------// METHOD SetFont( oFont ) CLASS TPrinter if oFont != nil ::oFont := oFont elseif ::oFont == nil DEFINE FONT ::oFont NAME "COURIER" SIZE 0,-12 OF Self endif return ::oFont //----------------------------------------------------------------------------// METHOD CharSay( nRow, nCol, cText ) CLASS TPrinter local nPxRow, nPxCol ::SetFont() nRow := Max(--nRow, 0) nCol := Max(--nCol, 0) nPxRow := nRow * ::GetTextHeight( "", ::oFont ) nPxCol := nCol * ::GetTextWidth( "B", ::oFont ) ::Say( nPxRow, nPxCol, cText, ::oFont ) return nil //----------------------------------------------------------------------------// METHOD CharWidth() CLASS TPrinter ::SetFont() return Int( ::nHorzRes() / ::GetTextWidth( "B", ::oFont ) ) //----------------------------------------------------------------------------// METHOD CharHeight() CLASS TPrinter ::SetFont() return Int( ::nVertRes() / ::GetTextHeight( "",::oFont ) ) //----------------------------------------------------------------------------// METHOD ImportWMF( cFile, lPlaceable ) CLASS TPrinter local hMeta, hOld, hWMF local aData := PrnGetSize( ::hDC ) local aInfo := Array( 5 ) DEFAULT lPlaceable := .T. if ! File( cFile ) return nil endif SaveDC( ::hDCOut ) #ifdef __CLIPPER__ if lPlaceable hMeta := GetPMetaFile( cFile, aInfo ) else hMeta := GetMetaFile( cFile ) endif #else if cFileExt( cFile ) == "EMF" hMeta := GetEnhMetaFile( cFile ) else hOld = GetPMetaFile( cFile, aInfo ) hMeta = WMF2EMF( hOld, ::hDCOut ) endif #endif ::SetIsoTropicMode() ::SetWindowExt( GetDeviceCaps( ::hDC, HORZRES ),; GetDeviceCaps( ::hDC, VERTRES ) ) // aData[ 1 ], aData[ 2 ] ) ::SetViewPortExt( GetDeviceCaps( ::hDC, HORZRES ),; GetDeviceCaps( ::hDC, VERTRES ) ) // aData[ 1 ], aData[ 2 ] ) if ! ::lMeta SetViewOrg( ::hDCOut, -::nXoffset, -::nYoffset ) endif SetBkMode( ::hDCOut, 1 ) #ifdef __CLIPPER__ PlayMetaFile( ::hDCOut, hMeta ) DeleteMetafile( hMeta ) #else if cFileExt( cFile ) == "EMF" PlayEnhMetafile( ::hDCOut, hMeta,, .t. ) else PlayMetaFile( ::hDCOut, hWMF := EMF2WMF( hMeta, ::hDCOut ) ) DeleteMetafile( hWMF ) endif DeleteEnhMetafile( hMeta ) #endif if ! Empty( hOld ) DeleteMetafile( hOld ) endif RestoreDC( ::hDCOut ) return nil //----------------------------------------------------------------------------// METHOD ImportRAW( cFile ) CLASS TPrinter if ! File( cFile ) return nil endif ImportRawFile( ::HDCOut, cFile ) return nil //----------------------------------------------------------------------------// METHOD SizeInch2Pix( nHeight, nWidth ) CLASS TPrinter // Inch2Pix() is for coordinates and is affected by page offsets // SizeInch2Pix is for converting width and height DEFAULT nWidth := 0, nHeight := 0 if nHeight <> 0 nHeight := Max( 0, ( nHeight * ::nVertRes() / ( ::nVertSize() / 25.4 ) ) ) endif if nWidth <> 0 nWidth := Max( 0, ( nWidth * ::nHorzRes() / ( ::nHorzSize() / 25.4 ) ) ) endif return { nWidth, nHeight } //----------------------------------------------------------------------------// function PrintBegin( cDoc, lUser, lPreview, xModel, lModal, lSelection ) local aPrn local cText, cDevice local nScan local oTestExcel // INICIO Leonardo 24-04-2012 // oTestExcel := TOleAuto():New("Excel.Application") If Ole2TxtError() # "S_OK" lTemExcel:= .F. Else lTemExcel:= .T. cFileCMD := cPath_Mod+"\"+StrZero(mNetUse,8)+".LHS" msginfo(cfilecmd) If File(cFileCMD) FErase(cFileCMD) EndIf nHCMD := FCreate(cFileCMD) nByte := 0 aPosCell:={} EndIf // FIM Leonardo 24-04-2012 // if xModel == nil return oPrinter := TPrinter():New( cDoc, lUser, lPreview,, lModal, lSelection ) endif cText := StrTran( GetProfString( "Devices" ),Chr(0), chr(13)+chr(10)) aPrn := Array( Mlcount( cText, 250 ) ) Aeval(aPrn, {|v,e| aPrn[e] := Trim(Memoline(cText, 250, e)) } ) if Valtype(xModel) == "N" if xModel < 0 .or. xModel > len(aPrn) nScan := 0 else nScan := xModel endif else if ( nScan := Ascan( aPrn, {|v| Upper( xModel ) == Upper( v ) } ) ) == 0 nScan = Ascan( aPrn, {|v| Upper( xModel ) $ Upper( v ) } ) endif endif if nScan == 0 MsgBeep() return oPrinter := TPrinter():New( cDoc, .T., lPreview,, lModal, lSelection ) endif cText := GetProfString( "Devices", aPrn[ nScan ] ) cDevice := aPrn[ nScan ] + "," + cText return oPrinter := TPrinter():New( cDoc, .f., lPreview, cDevice, lModal, lSelection ) //----------------------------------------------------------------------------// function PageBegin() ; oPrinter:StartPage() ; return nil //----------------------------------------------------------------------------// function PageEnd() ; oPrinter:EndPage(); return nil //----------------------------------------------------------------------------// function PrintEnd() if oPrinter:lMeta oPrinter:Preview() else oPrinter:End() endif oPrinter := nil // INICIO Leonardo 24-04-2012 // If lTemExcel FClose(nHCMD) EndIf // FIM Leonardo 24-04-2012 // return nil //----------------------------------------------------------------------------// function AGetPrinters() // returns an array with all the available printers local aPrinters, cText, cToken := Chr( 15 ) cText = StrTran( StrTran( StrTran( ; GetProfString( "Devices", 0 ), Chr( 0 ), cToken ), Chr( 13 ) ), Chr( 10 ) ) aPrinters = Array( Len( cText ) - Len( StrTran( cText, cToken ) ) ) AEval( aPrinters, { |cPrn, nEle | ; aPrinters[ nEle ] := StrToken( cText, nEle, cToken ) } ) return aPrinters //----------------------------------------------------------------------------// function SetPrintDefault( cModel ) local cDriver := StrToken( GetProfString( "Devices", cModel, "" ), 1, "," ) local cPort := StrToken( GetProfString( "Devices", cModel, "" ), 2, "," ) WriteProfString( "Windows", "Device", cModel + "," + cDriver + "," + cPort ) return nil *** FIM Segue abaixo a RPREVIEW: *** INICIO #include "FiveWin.ch" #Include "tsbutton.ch" #define DEVICE oWnd:cargo #define GO_POS 0 #define GO_UP 1 #define GO_DOWN 2 #define GO_LEFT 1 #define GO_RIGHT 2 #define GO_PAGE .T. #define VSCROLL_RANGE 20 * ::nZFactor #define HSCROLL_RANGE 20 * ::nZFactor #define TXT_FIRST LoadString( GetResources(), 07 ) #define TXT_PREVIOUS LoadString( GetResources(), 08 ) #define TXT_NEXT LoadString( GetResources(), 09 ) #define TXT_LAST LoadString( GetResources(), 10 ) #define TXT_ZOOM LoadString( GetResources(), 11 ) #define TXT_UNZOOM LoadString( GetResources(), 12 ) #define TXT_TWOPAGES LoadString( GetResources(), 13 ) #define TXT_ONEPAGE LoadString( GetResources(), 14 ) #define TXT_PRINT LoadString( GetResources(), 15 ) #define TXT_EXIT LoadString( GetResources(), 16 ) #define TXT_FILE LoadString( GetResources(), 17 ) #define TXT_PAGE LoadString( GetResources(), 18 ) #define TXT_PREVIEW LoadString( GetResources(), 03 ) #define TXT_PAGENUM LoadString( GetResources(), 19 ) #define TXT_A_WINDOW_PREVIEW_IS_ALLREADY_RUNNING ; LoadString( GetResources(), 20 ) #define TXT_GOTO_FIRST_PAGE ; LoadString( GetResources(), 21 ) #define TXT_GOTO_PREVIOUS_PAGE ; LoadString( GetResources(), 22 ) #define TXT_GOTO_NEXT_PAGE ; LoadString( GetResources(), 23 ) #define TXT_GOTO_LAST_PAGE ; LoadString( GetResources(), 24 ) #define TXT_ZOOM_THE_PREVIEW ; LoadString( GetResources(), 25 ) #define TXT_UNZOOM_THE_PREVIEW ; LoadString( GetResources(), 26 ) #define TXT_PREVIEW_ON_TWO_PAGES ; LoadString( GetResources(), 27 ) #define TXT_PREVIEW_ON_ONE_PAGE ; LoadString( GetResources(), 28 ) #define TXT_PRINT_CURRENT_PAGE ; LoadString( GetResources(), 29 ) #define TXT_EXIT_PREVIEW ; LoadString( GetResources(), 30 ) #define TXT_FACTOR ; LoadString( GetResources(), 31 ) #define TXT_ZOOM_FACTOR ; LoadString( GetResources(), 32 ) #define TXT_EXPORT_MSWORD ; LoadString( GetResources(), 33 ) #define MK_MBUTTON 16 static l2007 := .f. static bUserBtns := nil //----------------------------------------------------------------------------// CLASS TPreview DATA oWnd, oBar, oFont, oImageList DATA oDevice DATA oHand, oCursor DATA oMeta1, oMeta2, oSay, oFactor DATA oPage, oTwoPages, oZoom DATA oMenuZoom, oMenuTwoPages, oMenuUnZoom, oMenuOnePage DATA cResFile DATA aFactor, nPage, nZFactor DATA lTwoPages, lZoom, lExit DATA cPageNum DATA hOldRes, hNewRes CLASSDATA oWndMain METHOD New( oDevice, cFile ) METHOD Activate() METHOD BuildButtonBar() METHOD BuildWindow() METHOD BuildMenu() METHOD PaintMeta() METHOD NextPage() METHOD PrevPage() METHOD TopPage() METHOD BottomPage() METHOD TwoPages( lMenu ) METHOD Zoom( lMenu ) METHOD VScroll( nType, lPage, nSteps ) METHOD HScroll( nType, lPage, nSteps ) METHOD SetOrg1( nX, nY ) METHOD SetOrg2( nX, nY ) METHOD CheckKey( nKey, nFlags ) METHOD CheckMouseWheel( nKeys, nDelta, nXPos, nYPos ) METHOD SetFactor( nValue ) METHOD PrintPage() METHOD PrintPrv( oDlg, nOption, nPageIni, nPageEnd, lArq ) METHOD ExportToMSWord() METHOD SaveAsMenu() METHOD SaveAs( lPDF ) ENDCLASS //----------------------------------------------------------------------------// METHOD New( oDevice ) CLASS TPreview if oDevice == nil PRINTER oDevice PREVIEW PAGE ENDPAGE MsgInfo( oDevice:aMeta[ 1 ] ) // ENDPRINTER endif ::oDevice := oDevice ::nPage := 1 ::nZFactor := 1 ::lTwoPages := .F. ::lZoom := .F. ::lExit := .F. ::BuildWindow() return Self //----------------------------------------------------------------------------// METHOD Activate() CLASS TPreview ACTIVATE WINDOW ::oWnd MAXIMIZED ; ON RESIZE ::PaintMeta() ; ON UP ::VScroll( GO_UP ) ; ON DOWN ::VScroll( GO_DOWN ) ; ON PAGEUP ::VScroll( GO_UP, GO_PAGE) ; ON PAGEDOWN ::VScroll( GO_DOWN, GO_PAGE) ; ON LEFT ::HScroll( GO_LEFT ) ; ON RIGHT ::HScroll( GO_RIGHT ) ; ON PAGELEFT ::HScroll( GO_LEFT, GO_PAGE ) ; ON PAGERIGHT ::HScroll( GO_RIGHT, GO_PAGE ) ; VALID ( ::oWnd:oIcon := nil ,; ::oFont:End() ,; ::oMeta1:End() ,; ::oMeta2:End() ,; ::oDevice:End() ,; ::oHand:End() ,; ::oWnd := nil ,; If( IsAppThemed() .and. ! l2007, ::oImageList:End(),),; ::lExit := .T. ,; .T. ) if ::oDevice:lPrvModal StopUntil( { || ::lExit } ) endif return nil //----------------------------------------------------------------------------// METHOD BuildButtonBar() CLASS TPreview local oImageList, oReBar, oBar, oHand, oWndMain local l97Look := ::oWndMain != nil .and. ::oWndMain:oBar != nil .and. ; Len( ::oWndMain:oBar:aControls ) > 0 .and. ; ::oWndMain:oBar:aControls[ 1 ]:l97Look DEFINE CURSOR ::oHand HAND if WndMain() != nil if WndMain():oBar != nil oBar = WndMain():oBar if oBar != nil .and. Upper( oBar:ClassName() ) == "TBAR" //.and. oBar:l2007 l2007 = .T. endif endif endif if IsAppThemed() .and. ! l2007 DEFINE IMAGELIST oImageList SIZE 16, 16 oImageList:AddMasked( TBitmap():Define( "top2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "previous2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "next2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "bottom2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "zoom2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "two_pages2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "printer2",, ::oWnd ), nRGB( 255, 0, 255 ) ) oImageList:AddMasked( TBitmap():Define( "save",, ::oWnd ), nRGB( 255, 0, 255 ) ) oImageList:AddMasked( TBitmap():Define( "word",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "exit2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "unzoom2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "one_page2",, ::oWnd ), nRGB( 192, 192, 192 ) ) oImageList:AddMasked( TBitmap():Define( "excel",, ::oWnd ), nRGB( 192, 192, 192 ) ) ::oImageList = oImageList oReBar = TReBar():New( ::oWnd ) DEFINE TOOLBAR oBar OF oReBar SIZE 25, 25 IMAGELIST oImageList ::oBar = oBar oReBar:InsertBand( oBar ) oBar:nHeight -= 2 DEFINE TBBUTTON OF oBar ; ACTION ::TopPage() ; TOOLTIP Strtran( TXT_FIRST, "&", "" ) ; MESSAGE TXT_GOTO_FIRST_PAGE DEFINE TBBUTTON OF oBar ; ACTION ::PrevPage() ; TOOLTIP Strtran( TXT_PREVIOUS, "&", "" ) ; MESSAGE TXT_GOTO_PREVIOUS_PAGE DEFINE TBBUTTON OF oBar ; ACTION ::NextPage() ; TOOLTIP Strtran( TXT_NEXT, "&", "" ) ; MESSAGE TXT_GOTO_NEXT_PAGE DEFINE TBBUTTON OF oBar ; ACTION ::BottomPage() ; TOOLTIP Strtran( TXT_LAST, "&", "" ) ; MESSAGE TXT_GOTO_LAST_PAGE DEFINE TBSEPARATOR OF oBar DEFINE TBBUTTON OF oBar ; ACTION ::Zoom() ; TOOLTIP Strtran( TXT_ZOOM, "&", "" ) ; MESSAGE TXT_ZOOM_THE_PREVIEW DEFINE TBBUTTON OF oBar ; ACTION ::TwoPages() ; TOOLTIP StrTran( Strtran( TXT_TWOPAGES, "&", "" ), "á", "a" ) ; MESSAGE TXT_PREVIEW_ON_TWO_PAGES DEFINE TBSEPARATOR OF oBar DEFINE TBBUTTON OF oBar ; ACTION ::PrintPage() ; TOOLTIP Strtran(TXT_PRINT,"&","") ; MESSAGE TXT_PRINT_CURRENT_PAGE DEFINE TBMENU OF oBar ; ACTION ::SaveAs( .f. ) ; TOOLTIP "SaveAs" ; MESSAGE "Save As Word Document" ; MENU ::SaveAsMenu() DEFINE TBBUTTON OF oBar ; ACTION ::ExportToMSWord() ; TOOLTIP TXT_EXPORT_MSWORD ; MESSAGE TXT_EXPORT_MSWORD DEFINE TBSEPARATOR OF oBar DEFINE TBBUTTON OF oBar ; MESSAGE "Salva Formato .XLS" ; ACTION GeraXLS(::oWnd) ; TOOLTIP "Salva Formato .XLS" DEFINE TBBUTTON OF oBar ; ACTION ::oWnd:End() ; TOOLTIP Strtran( TXT_EXIT, "&", "" ) ; MESSAGE TXT_EXIT_PREVIEW else if oBar != nil ///.and. oBar:l2007 DEFINE BUTTONBAR oBar SIZE 26, If( LargeFonts(), 30, 26 ) OF ::oWnd 2007 oBar:bPainted = { || oBar:Say( 7, 285+50, "Factor:",,, ::oFont, .T., .T. ),; If( Len( ::oDevice:aMeta ) > 1,; oBar:Say( 7, 380+50, ::cPageNum + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( ::oDevice:aMeta ) ) ),,, ::oFont, .T., .T. ),; oBar:Say( 7, 380+50, ::cPageNum + LTrim( Str( ::nPage, 4, 0 ) ),; ,,, ::oFont, .T., .T. ) ) } else DEFINE BUTTONBAR oBar _3D SIZE 26, If( LargeFonts(), 30, 26 ) OF ::oWnd endif ::oBar = oBar if l97Look DEFINE BUTTON RESOURCE "Top" OF oBar ; MESSAGE TXT_GOTO_FIRST_PAGE ; ACTION ::TopPage() ; TOOLTIP Strtran( TXT_FIRST, "&", "" ) NOBORDER DEFINE BUTTON RESOURCE "Previous" OF oBar ; MESSAGE TXT_GOTO_PREVIOUS_PAGE ; ACTION ::PrevPage() ; TOOLTIP Strtran( TXT_PREVIOUS, "&", "" ) NOBORDER DEFINE BUTTON RESOURCE "Next" OF oBar ; MESSAGE TXT_GOTO_NEXT_PAGE ; ACTION ::NextPage() ; TOOLTIP Strtran( TXT_NEXT, "&", "" ) NOBORDER DEFINE BUTTON RESOURCE "Bottom" OF oBar ; MESSAGE TXT_GOTO_LAST_PAGE ; ACTION ::BottomPage() ; TOOLTIP Strtran( TXT_LAST, "&", "" ) NOBORDER DEFINE BUTTON ::oZoom RESOURCE "Zoom" OF oBar GROUP ; MESSAGE TXT_ZOOM_THE_PREVIEW ; ACTION ::Zoom() ; TOOLTIP Strtran( TXT_ZOOM, "&", "" ) NOBORDER DEFINE BUTTON ::oTwoPages RESOURCE "Two_Pages" OF oBar ; MESSAGE TXT_PREVIEW_ON_TWO_PAGES ; ACTION ::TwoPages() ; TOOLTIP Strtran( TXT_TWOPAGES, "&", "" ) NOBORDER DEFINE BUTTON RESOURCE "Printer" OF oBar GROUP ; MESSAGE TXT_PRINT_CURRENT_PAGE ; ACTION ::PrintPage() ; TOOLTIP Strtran( TXT_PRINT, "&", "" ) NOBORDER DEFINE BUTTON RESOURCE "Save" OF oBar ; MENU ::SaveAsMenu() ; MESSAGE "Save as DOC/PDF" ; ACTION This:ShowPopUp() ; TOOLTIP "Save as Doc/Pdf" DEFINE BUTTON RESOURCE "Word" OF oBar NOBORDER ; MESSAGE TXT_EXPORT_MSWORD ; ACTION ::ExportToMSWord() ; TOOLTIP TXT_EXPORT_MSWORD if ! Empty( bUserBtns ) SetResources( ::hOldRes ) Eval( bUserBtns, Self, oBar ) SetResources( ::hNewRes ) endif DEFINE BUTTON RESOURCE "Excel" OF oBar GROUP ; MESSAGE "Salva Formato .XLS" ; ACTION GeraXLS(::oWnd) ; TOOLTIP "Salva Formato .XLS" NOBORDER DEFINE BUTTON RESOURCE "Exit" OF oBar GROUP ; MESSAGE TXT_EXIT_PREVIEW ; ACTION ::oWnd:End() ; TOOLTIP Strtran( TXT_EXIT, "&", "" ) NOBORDER else DEFINE BUTTON RESOURCE "Top2" OF oBar ; MESSAGE TXT_GOTO_FIRST_PAGE ; ACTION ::TopPage() ; TOOLTIP Strtran( TXT_FIRST, "&", "" ) DEFINE BUTTON RESOURCE "Previous2" OF oBar ; MESSAGE TXT_GOTO_PREVIOUS_PAGE ; ACTION ::PrevPage() ; TOOLTIP Strtran( TXT_PREVIOUS, "&", "" ) DEFINE BUTTON RESOURCE "Next2" OF oBar ; MESSAGE TXT_GOTO_NEXT_PAGE ; ACTION ::NextPage() ; TOOLTIP Strtran( TXT_NEXT, "&", "" ) DEFINE BUTTON RESOURCE "Bottom2" OF oBar ; MESSAGE TXT_GOTO_LAST_PAGE ; ACTION ::BottomPage() ; TOOLTIP Strtran( TXT_LAST, "&", "" ) DEFINE BUTTON ::oZoom RESOURCE "Zoom2" OF oBar GROUP ; MESSAGE TXT_ZOOM_THE_PREVIEW ; ACTION ::Zoom() ; TOOLTIP Strtran( TXT_ZOOM, "&", "" ) DEFINE BUTTON ::oTwoPages RESOURCE "Two_Pages2" OF oBar ; MESSAGE TXT_PREVIEW_ON_TWO_PAGES ; ACTION ::TwoPages() ; TOOLTIP Strtran( TXT_TWOPAGES, "&", "" ) DEFINE BUTTON RESOURCE "Printer2" OF oBar GROUP ; MESSAGE TXT_PRINT_CURRENT_PAGE ; ACTION ::PrintPage() ; TOOLTIP Strtran( TXT_PRINT, "&", "" ) DEFINE BUTTON RESOURCE "Save" OF oBar ; MENU ::SaveAsMenu() ; MESSAGE "Save as DOC/PDF" ; ACTION This:ShowPopUp() ; TOOLTIP "Save as Doc/Pdf" DEFINE BUTTON RESOURCE "Word" OF oBar ; MESSAGE TXT_EXPORT_MSWORD ; ACTION ::ExportToMSWord() ; TOOLTIP TXT_EXPORT_MSWORD if ! Empty( bUserBtns ) SetResources( ::hOldRes ) Eval( bUserBtns, Self, oBar ) SetResources( ::hNewRes ) endif DEFINE BUTTON RESOURCE "Excel" OF oBar GROUP ; MESSAGE "Salva Formato .XLS" ; ACTION GeraXLS(::oWnd) ; TOOLTIP "Salva Formato .XLS" DEFINE BUTTON RESOURCE "Exit2" OF oBar GROUP ; MESSAGE TXT_EXIT_PREVIEW ; ACTION ::oWnd:End() ; TOOLTIP Strtran( TXT_EXIT, "&", "" ) endif AEval( oBar:aControls, { | o | o:oCursor := ::oHand } ) endif return nil //----------------------------------------------------------------------------// METHOD BuildWindow() CLASS TPreview local oIcon, cTitle := "FiveWin Printing Preview", oCursor local oThis := Self DEFAULT ::oWndMain := WndMain() ::hOldRes := GetResources() #ifdef __CLIPPER__ ::cResFile := "Preview.dll" #else if ! IsWin64() ::cResFile := "Prev32.dll" else ::cResFile = "Prev64.dll" endif #endif if SetResources( ::cResFile ) < 32 MsgStop( ::cResFile + " not found, imposible to continue",; "FiveWin Printing Error" ) return nil endif ::hNewRes := GetResources() if ::oDevice != nil cTitle = ::oDevice:cDocument endif if ::oWndMain != nil oIcon = ::oWndMain:oIcon else DEFINE ICON oIcon RESOURCE "Print" endif DEFINE FONT ::oFont NAME GetSysFont() SIZE 0, -12 if !::oDevice:lPrvModal .and. ::oWndMain != nil .and. ; Upper( ::oWndMain:ClassName() ) == "TMDIFRAME" DEFINE WINDOW ::oWnd ; TITLE cTitle ; COLOR CLR_BLACK,CLR_LIGHTGRAY ; ICON oIcon ; VSCROLL HSCROLL else DEFINE WINDOW ::oWnd FROM 0, 0 TO 24, 80 ; TITLE cTitle ; COLOR CLR_BLACK,CLR_LIGHTGRAY ; ICON oIcon ; VSCROLL HSCROLL MENU ::BuildMenu() endif ::oWnd:SetFont( ::oFont ) ::oWnd:oVScroll:SetRange( 0, 0 ) ::oWnd:oHScroll:SetRange( 0, 0 ) ::cPageNum = TXT_PAGENUM ::BuildButtonBar() #ifdef __CLIPPER__ SET MESSAGE OF ::oWnd TO TXT_PREVIEW CENTERED ; NOINSET CLOCK DATE KEYBOARD #else if l2007 SET MESSAGE OF ::oWnd TO TXT_PREVIEW CENTERED ; NOINSET CLOCK DATE KEYBOARD 2007 else DEFINE STATUSBAR OF ::oWnd PROMPT " " + TXT_PREVIEW endif #endif ::oMeta1 := TMetaFile():New( 0, 0, 0, 0,; ::oDevice:aMeta[ 1 ],; ::oWnd,; CLR_BLACK,; CLR_WHITE,; ::oDevice:nHorzRes(),; ::oDevice:nVertRes() ) DEFINE CURSOR ::oCursor RESOURCE "LUPA" ::oMeta1:oCursor := ::oCursor ::oMeta1:blDblClick := { | nRow, nCol, nKeyFlags | ; ::SetOrg1( nCol, nRow, nKeyFlags ) } ::oMeta1:bKeyDown := { | nKey, nFlags | ::CheckKey( nKey, nFlags ) } ::oMeta1:bMouseWheel := { | nKeys, nDelta, nXPos, nYPos | ; ::CheckMouseWheel( nKeys, nDelta, nXPos, nYPos ) } #ifndef __XPP__ // XBPP bug. Warning: don't change this into #ifdef __CLIPPER__ ::oMeta2 := TMetaFile():New( 0, 0, 0, 0, "",; ::oWnd, CLR_BLACK, CLR_WHITE, ::oDevice:nHorzRes(),; ::oDevice:nVertRes() ) #else ::oMeta2 := TMetaFile():New():_New( 0, 0, 0, 0, "",; ::oWnd, CLR_BLACK, CLR_WHITE, ::oDevice:nHorzRes(),; ::oDevice:nVertRes() ) #endif ::oMeta2:oCursor = ::oCursor ::oMeta2:blDblClick := { | nRow, nCol, nKeyFlags | ; ::SetOrg2( nCol, nRow, nKeyFlags ) } ::oMeta2:hide() ::SetFactor() if ! l2007 @ 7, 285+50 SAY ::oSay PROMPT "Factor:" ; SIZE 45, 15 PIXEL OF ::oBar FONT ::oFont ::oSay:lTransparent = .T. endif @ 3, 325+50 COMBOBOX ::oFactor VAR ::nZFactor ; ITEMS { "1", "2", "3", "4", "5", "6", "7", "8", "9" } ; OF ::oBar FONT ::oFont PIXEL SIZE 35,200 ; ON CHANGE oThis:SetFactor( oThis:nZFactor ) if ! l2007 if Len( ::oDevice:aMeta ) > 1 @ 7, 370 + 50 SAY ::oPage PROMPT TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( ::oDevice:aMeta ) ) ) ; SIZE 180, 15 PIXEL OF ::oBar FONT ::oFont else @ 7, 370 + 50 SAY ::oPage PROMPT TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) ; SIZE 180, 15 PIXEL OF ::oBar FONT ::oFont endif ::oPage:lTransparent = .T. endif if IsAppThemed() .or. l2007 FixSays( ::oBar:hWnd ) endif #ifndef __XPP__ ::oFactor:Set3dLook( .T. ) #endif SetResources( ::hOldRes ) ::oWnd:oHScroll:bPos := { | nPos | ::HScroll( GO_POS, .f., nPos ) } ::oWnd:oVScroll:bPos := { | nPos | ::VScroll( GO_POS, .f., nPos ) } return nil //----------------------------------------------------------------------------// METHOD BuildMenu() CLASS TPreview local nFor, oMenu local lThemed := IsAppThemed() local cPrinter := If( lThemed, "Printer2", "Printer" ) local cTop := If( lThemed, "Top2", "Top" ) local cPrevious := If( lThemed, "Previous2", "Previous" ) local cNext := If( lThemed, "Next2", "Next" ) local cBottom := If( lThemed, "Bottom2", "Bottom" ) local cZoom := If( lThemed, "Zoom2", "Zoom" ) local cUnZoom := If( lThemed, "UnZoom2", "UnZoom" ) local cOne_Page := If( lThemed, "One_page2", "One_page" ) local cTwo_Pages := If( lThemed, "Two_pages2", "Two_pages" ) local cExit := If( lThemed, "Exit2", "Exit" ) ::aFactor := Array( 9 ) MENU oMenu MENUITEM TXT_FILE MENU MENUITEM TXT_PRINT ACTION ::PrintPage() ; MESSAGE TXT_PRINT_CURRENT_PAGE RESOURCE cPrinter MENUITEM "&Salva Formato .XLS" ACTION GeraXLS() ; MESSAGE "Salva Formato .XLS" RESOURCE "Excel" SEPARATOR MENUITEM TXT_EXIT ACTION ::oWnd:End() ; MESSAGE TXT_EXIT_PREVIEW RESOURCE cExit ENDMENU MENUITEM TXT_PAGE MENU MENUITEM TXT_FIRST ACTION ::TopPage() ; MESSAGE TXT_GOTO_FIRST_PAGE RESOURCE cTop MENUITEM TXT_PREVIOUS ACTION ::PrevPage() ; MESSAGE TXT_GOTO_PREVIOUS_PAGE RESOURCE cPrevious MENUITEM TXT_NEXT ACTION ::NextPage() ; MESSAGE TXT_GOTO_NEXT_PAGE RESOURCE cNext MENUITEM TXT_LAST ACTION ::BottomPage() ; MESSAGE TXT_GOTO_LAST_PAGE RESOURCE cBottom SEPARATOR MENUITEM ::oMenuZoom PROMPT TXT_ZOOM ACTION ::Zoom( .T. ) ; MESSAGE TXT_ZOOM_THE_PREVIEW RESOURCE cZoom MENUITEM ::oMenuUnZoom PROMPT TXT_UNZOOM ACTION ::Zoom( .T. ) ; MESSAGE TXT_UNZOOM_THE_PREVIEW RESOURCE cUnZoom MENUITEM "&Factor" MESSAGE TXT_ZOOM_FACTOR MENU for nFor := 1 to Len( ::aFactor ) MENUITEM ::aFactor[ nFor ] ; PROMPT "&" + LTrim( Str( nFor ) ) ; MESSAGE "Factor " + LTrim( Str( nFor ) ) ; ACTION ( ::oFactor:Set( oMenuItem:nHelpId ),; Eval( ::oFactor:bChange ) ) next ENDMENU SEPARATOR MENUITEM ::oMenuTwoPages PROMPT TXT_TWOPAGES ACTION ::TwoPages( .T. ) ; ENABLED ; MESSAGE TXT_PREVIEW_ON_TWO_PAGES RESOURCE cTwo_Pages MENUITEM ::oMenuOnePage PROMPT TXT_ONEPAGE ACTION ::TwoPages(.T.) ; MESSAGE TXT_PREVIEW_ON_ONE_PAGE RESOURCE cOne_Page ENDMENU ENDMENU ::oMenuUnZoom:Disable() ::oMenuOnePage:Disable() return oMenu //----------------------------------------------------------------------------// METHOD PaintMeta() CLASS TPreview local oCoors1, oCoors2 local aFiles := ::oDevice:aMeta // DEVICE local nWidth, nHeight, nFactor, nMetaWidth if ::oWnd != nil .and. IsIconic( ::oWnd:hWnd ) return nil endif do case case ! ::lTwoPages if ! ::lZoom if ::oDevice:nHorzSize() >= ; // landscape (apaisado) // DEVICE ::oDevice:nVertSize() nFactor := .8 // .4 else nFactor := .40 // .25 endif else nFactor := .47 endif if ::oWnd != nil nWidth = ::oWnd:nWidth() - If( ::lZoom, 20, 0 ) nHeight = ::oWnd:nHeight() - If( ::lZoom .and. ::nZFactor > 1, 20, 0 ) - 10 - ; If( LargeFonts(), 100, 80 ) if ! ::lZoom nMetaWidth = ( nHeight - 40 ) * nFactor else nMetaWidth = nWidth * nFactor endif oCoors1 := TRect():New( 40,; Max( ( nWidth / 2 ) - nMetaWidth, 10 ),; nHeight,; Min( ( nWidth / 2 ) + nMetaWidth, nWidth - 20 ) ) ::oMeta2:Hide() ::oMeta1:SetCoors( oCoors1 ) ::oMeta1:Refresh() endif case ::lTwoPages nFactor := .4 aFiles := ::oDevice:aMeta // DEVICE nWidth := ::oWnd:nWidth() nHeight := ::oWnd:nHeight() - 10 - If( LargeFonts(), 100, 80 ) nMetaWidth = Min( ( nHeight - 40 ) * nFactor, ( nWidth - 60 ) / 4 ) oCoors1 := TRect():New( 40,; ( nWidth / 4 ) - nMetaWidth,; nHeight,; ( nWidth / 4 ) + nMetaWidth ) oCoors2 := TRect():New( 40,; ( nWidth / 4 ) - nMetaWidth + ( nWidth / 2 ),; nHeight,; ( nWidth / 4 ) + nMetaWidth + ( nWidth / 2 ) ) if ::nPage == Len( aFiles ) ::oMeta2:SetFile( "" ) else ::oMeta2:SetFile( aFiles[ ::nPage + 1 ] ) endif ::oMeta1:SetCoors( oCoors1 ) ::oMeta2:SetCoors( oCoors2 ) ::oMeta1:Refresh() ::oMeta2:Show() endcase ::oMeta1:SetFocus() return nil //----------------------------------------------------------------------------// METHOD NextPage() CLASS TPreview local hOldRes := GetResources() local aFiles := ::oDevice:aMeta // DEVICE if ::nPage >= Len( aFiles ) MsgBeep() return nil endif ::nPage++ SET RESOURCES TO ::cResFile ::oMeta1:SetFile( aFiles[ ::nPage ] ) if ! l2007 ::oPage:SetText( TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( aFiles ) ) ) ) endif ::oBar:Refresh() ::oMeta1:Refresh() if ::lTwoPages if Len( aFiles ) >= ::nPage + 1 ::oMeta2:SetFile( aFiles[ ::nPage + 1 ] ) else ::oMeta2:SetFile( "" ) endif ::oMeta2:Refresh() endif ::oMeta1:SetFocus() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD PrevPage() CLASS TPreview local hOldRes := GetResources() local aFiles := ::oDevice:aMeta // DEVICE if ::nPage == 1 MsgBeep() return nil endif ::nPage-- SET RESOURCES TO ::cResFile ::oMeta1:SetFile( aFiles[ ::nPage ] ) if ! l2007 ::oPage:SetText( TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( aFiles ) ) ) ) endif ::oBar:Refresh() ::oMeta1:Refresh() if ::lTwoPages if Len( aFiles ) >= ::nPage + 1 ::oMeta2:SetFile( aFiles[ ::nPage + 1 ] ) else ::oMeta2:SetFile( "" ) endif ::oMeta2:Refresh() endif ::oMeta1:SetFocus() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD TopPage() CLASS TPreview local hOldRes := GetResources() local aFiles := ::oDevice:aMeta // DEVICE if ::nPage == 1 MsgBeep() return nil endif ::nPage = 1 SET RESOURCES TO ::cResFile ::oMeta1:SetFile( aFiles[ ::nPage ] ) if ! l2007 ::oPage:SetText( TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( aFiles ) ) ) ) endif ::oBar:Refresh() ::oMeta1:Refresh() if ::lTwoPages if Len( aFiles ) >= ::nPage + 1 ::oMeta2:SetFile( aFiles[ ::nPage + 1 ] ) else ::oMeta2:SetFile( "" ) endif ::oMeta2:Refresh() endif ::oMeta1:SetFocus() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD BottomPage() CLASS TPreview local hOldRes := GetResources() local aFiles := ::oDevice:aMeta // DEVICE if ::nPage == Len( aFiles ) MsgBeep() return nil endif ::nPage = Len( aFiles ) SET RESOURCES TO ::cResFile ::oMeta1:SetFile( aFiles[ ::nPage ] ) if ! l2007 ::oPage:SetText( TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ; LTrim( Str( Len( aFiles ) ) ) ) endif ::oBar:Refresh() ::oMeta1:Refresh() if ::lTwoPages ::oMeta2:SetFile( "" ) ::oMeta2:Refresh() endif ::oMeta1:SetFocus() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD TwoPages( lMenu ) CLASS TPreview local hOldRes := GetResources() SET RESOURCES TO ::cResFile DEFAULT lMenu := .F. ::lTwoPages := ! ::lTwoPages if ::lTwoPages if Len( ::oDevice:aMeta) == 1 // solo hay una pagina // DEVICE ::lTwoPages := ! ::lTwoPages MsgBeep() SetResources( hOldRes ) return nil endif if ::oDevice:nHorzSize() >= ; // Apaisado // DEVICE ::oDevice:nVertSize() // DEVICE ::lTwoPages := ! ::lTwoPages MsgBeep() SetResources( hOldRes ) return nil endif if ::lZoom ::Zoom( .T. ) endif if ! IsAppThemed() .or. Upper( ::oBar:ClassName() ) == "TBAR" ::oTwoPages:FreeBitmaps() ::oTwoPages:LoadBitmaps( "One_Page2" ) ::oTwoPages:cMsg := TXT_PREVIEW_ON_ONE_PAGE ::oTwoPages:cTooltip := StrTran( TXT_ONEPAGE, "&", "" ) else ::oBar:ChangeBitmap( 6, 10+2 ) ::oBar:SetTooltip( 6, StrTran( TXT_ONEPAGE, "&", "" ) ) ::oBar:SetMessage( 6, TXT_PREVIEW_ON_ONE_PAGE ) endif if ::oWnd:oMenu != nil ::oMenuTwoPages:Disable() ::oMenuOnePage:Enable() endif else if ! IsAppThemed() .or. Upper( ::oBar:ClassName() ) == "TBAR" ::oTwoPages:FreeBitmaps() ::oTwoPages:LoadBitmaps( "Two_Pages2" ) ::oTwoPages:cMsg := TXT_PREVIEW_ON_TWO_PAGES ::oTwoPages:cTooltip := StrTran( TXT_TWOPAGES, "&", "" ) else ::oBar:ChangeBitmap( 6, 6 ) ::oBar:SetTooltip( 6, StrTran( TXT_TWOPAGES, "&", "" ) ) ::oBar:SetMessage( 6, TXT_PREVIEW_ON_TWO_PAGES ) endif if ::oWnd:oMenu != nil ::oMenuTwoPages:Enable() ::oMenuOnePage:Disable() endif endif if lMenu .and. ! IsAppThemed() ::oTwoPages:Refresh() endif ::oWnd:Refresh() ::PaintMeta() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD Zoom( lMenu ) CLASS TPreview local hOldRes := GetResources() SET RESOURCES TO ::cResFile DEFAULT lMenu := .F. ::lZoom := ! ::lZoom if ::lZoom if ::lTwoPages ::TwoPages( .T. ) endif if ! IsAppThemed() .or. l2007 ::oZoom:FreeBitmaps() ::oZoom:LoadBitmaps( "Unzoom2" ) ::oZoom:cMsg := TXT_UNZOOM_THE_PREVIEW ::oZoom:cTooltip := StrTran( TXT_UNZOOM, "&", "" ) else ::oBar:ChangeBitmap( 5, 9+2 ) ::oBar:SetTooltip( 5, StrTran( TXT_UNZOOM, "&", "" ) ) ::oBar:SetMessage( 5, TXT_UNZOOM_THE_PREVIEW ) endif if ::oWnd:oMenu != nil ::oMenuZoom:Disable() ::oMenuUnZoom:Enable() endif ::oWnd:oVScroll:SetRange( 1, VSCROLL_RANGE ) if ::nZFactor > 1 ::oWnd:oHScroll:SetRange( 1, HSCROLL_RANGE ) endif ::oMeta1:ZoomIn() else if ! IsAppThemed() .or. l2007 ::oZoom:FreeBitmaps() ::oZoom:LoadBitmaps( "Zoom2" ) ::oZoom:cMsg := TXT_ZOOM_THE_PREVIEW ::oZoom:cTooltip := StrTran( TXT_ZOOM, "&", "" ) else ::oBar:ChangeBitmap( 5, 5 ) ::oBar:SetTooltip( 5, StrTran( TXT_ZOOM, "&", "" ) ) ::oBar:SetMessage( 5, TXT_ZOOM_THE_PREVIEW ) endif if ::oWnd:oMenu != nil ::oMenuZoom:Enable() ::oMenuUnZoom:Disable() endif ::oWnd:oVScroll:SetRange( 0, 0 ) ::oWnd:oHScroll:SetRange( 0, 0 ) ::oMeta1:ZoomOut() ::nZFactor = 1 if ::oWnd:oMenu != nil AEval( ::aFactor, { | val, elem | val:SetCheck( ( elem == 1 ) ) } ) endif ::oFactor:Set( 1 ) endif if lMenu .and. ! IsAppThemed() ::oZoom:Refresh() endif ::PaintMeta() SetResources( hOldRes ) return nil //----------------------------------------------------------------------------// METHOD VScroll( nType, lPage, nSteps ) CLASS TPreview local nYfactor, nYorig, nStep DEFAUL Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 14, 2012 Author Report Share Posted May 14, 2012 Gilmer, boa tarde. Ajuda !!! Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
Luiz Arruda (ICO) Posted May 14, 2012 Report Share Posted May 14, 2012 Analisando melhor suas respostas deparei com esta; citação:Ico, boa tarde. No PREV32.DLL inseri a imagem da EXCEL no botão. No PRINTER.PRG fiz as mesmas mudanças do FW 16. No RPREVIEW.PRG fiz também as mesmas mudanças do FW 16. Quando dou o Preview do relatório, dá tudo certo. Quando clico no botão EXCEL, dá erro, onde a variável que informa é a declarada e utilizada no PRINTER.PRG, muito estranho. Ajude-me por favor. Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour id=quote>id=quote>Logo, os fontes/classes alterados estão sim sendo compilados, vc. deverá analisar suas alterações e ver se está tudo certo.. Luiz Arruda Corumbá-MS ico.corumba@gmail.com | http://www.facebook.com/profile.php?id=100000933378029 FiveWin 9.04 xHarbour PellesC Bcc. Quote Link to comment Share on other sites More sharing options...
leo@lhsistemas.com Posted May 16, 2012 Author Report Share Posted May 16, 2012 Ico, boa tarde. Sim as modifcações são compiladas, pois, no xDev vejo compilando a RPREVIEW.PRG e PRINTER.PRG, só que uma variavel chamada cFileCMD criada como publica no PRINTER.PRG, não existe no RPREVIEW.PRG, ocasionando o erro. Parace que o FiveWin + xHarbour, ignora a minha PRINTER.PRG na execução, e utiliza a interna da bibliteca nativa. Leonardo Guimarães Vitória-ES FWH + xDevStudio + xHarbour Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.