#include "FiveWin.ch"
#include "Mail.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 MK_MBUTTON 16
static hLib // pdf
static oWnd, oBar, oMeta1, oMeta2,;
oPage, oTwoPages, oZoom, oMenuZoom, oMenuTwoPages,;
oMenuUnZoom, oMenuOnePage, oFactor, cResFile
static aFactor
static nPage, nZFactor
static lTwoPages, lZoom
//----------------------------------------------------------------------------//
function main( oDevice, oReport )
local aFiles := {""}
local hOldRes := GetResources()
local oSay
local nFor
local oWndMain := WndMain(), oIcon, oCursor, oMenu, oBrush, oFont
local l97Look := oWndMain != nil .and. oWndMain:oBar != nil .and. ;
Len( oWndMain:oBar:aControls ) > 0 .and. ;
oWndMain:oBar:aControls[ 1 ]:l97Look
local lExit := .F.
local oHand, oImageList, oReBar, oSay2
//local aImpre := aGetPrinters(), oCbx, cCbx:=PrnGetName(), cImpre := cCbx // mcn
// para seleccionar impresora (mcn)
local aImpre := {"Impresora HP"}, cCbx, cImpre := cCbx // mcn
#ifdef __CLIPPER__
cResFile := "Preview.dll"
#else
if ! IsWin64()
cResFile := "Prev32.dll"
else
cResFile = "Prev64.dll"
endif
#endif
if SetResources(cResFile) < 32
MsgStop(cResFile + " no encontrado, imposible continuar.",;
" E R R O R ")
RETU nil
endif
if oWnd != nil
MsgStop(TXT_A_WINDOW_PREVIEW_IS_ALLREADY_RUNNING)
SetResources(hOldRes)
RETU nil
endif
if oWndMain != nil
oIcon = oWndMain:oIcon
else
DEFINE ICON oIcon RESOURCE "Print"
endif
//lExit := .T.
DEFINE FONT oFont NAME GetSysFont() SIZE 0,-12
DEFINE CURSOR oCursor RESOURCE "Lupa"
DEFINE WINDOW oWnd FROM 0, 0 TO 24, 80 ;
TITLE "oDevice:cDocument "+FWVERSION ;
COLOR CLR_BLACK,CLR_LIGHTGRAY ;
ICON oIcon ;
VSCROLL HSCROLL
// So IsAppThemed_ed() is properly detected as the window is already built
// PDF
//oWnd:SetMenu( BuildMenu( oDevice:aMeta, oReport ) )
oWnd:SetFont(oFont)
oWnd:oVScroll:SetRange(0,0)
oWnd:oHScroll:SetRange(0,0)
DEFINE CURSOR oHand HAND
if IsAppThemed_ed() // PDF
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 ) )
// pdf
// Actualizar change bitmaps
oImageList:AddMasked( TBitmap():Define( "save",, oWnd ), nRGB( 255, 0, 255 ) )
oImageList:AddMasked( TBitmap():Define( "mail",, oWnd ), nRGB( 255, 255, 255 ) )
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 ) )
oReBar = TReBar():New( oWnd )
DEFINE TOOLBAR oBar OF oReBar SIZE 25, 25 IMAGELIST oImageList
oReBar:InsertBand( oBar )
oBar:nHeight -= 2
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_FIRST,"&","") ;
MESSAGE TXT_GOTO_FIRST_PAGE
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_PREVIOUS,"&","") ;
MESSAGE TXT_GOTO_PREVIOUS_PAGE
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_NEXT,"&","") ;
MESSAGE TXT_GOTO_NEXT_PAGE
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_LAST,"&","") ;
MESSAGE TXT_GOTO_LAST_PAGE
DEFINE TBSEPARATOR OF oBar
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_ZOOM,"&","") ;
MESSAGE TXT_ZOOM_THE_PREVIEW
DEFINE TBBUTTON OF oBar ;
TOOLTIP StrTran( Strtran(TXT_TWOPAGES,"&",""), "á", "a" ) ;
MESSAGE TXT_PREVIEW_ON_TWO_PAGES
DEFINE TBSEPARATOR OF oBar
DEFINE TBBUTTON OF oBar ;
TOOLTIP Strtran(TXT_PRINT,"&","") ;
MESSAGE TXT_PRINT_CURRENT_PAGE
// PDF
DEFINE TBBUTTON OF oBar ;
TOOLTIP "Exportar a PDF" ;
MESSAGE "Exporta a formato PDF"
DEFINE TBBUTTON OF oBar ;
TOOLTIP "Enviar Correo Electr¢nico" ;
MESSAGE "Enviar por Correo Electrónico"
DEFINE TBSEPARATOR OF oBar
DEFINE TBBUTTON OF oBar ;
ACTION oWnd:End() ;
TOOLTIP Strtran(TXT_EXIT,"&","") ;
MESSAGE TXT_EXIT_PREVIEW
else
DEFINE BUTTONBAR oBar _3D SIZE 26, If( LargeFonts(), 30, 26 ) OF oWnd
oBar:bRClicked := {|| nil }
if l97Look
DEFINE BUTTON RESOURCE "Top" OF oBar ;
MESSAGE TXT_GOTO_FIRST_PAGE ;
TOOLTIP Strtran(TXT_FIRST,"&","") NOBORDER
DEFINE BUTTON RESOURCE "Previous" OF oBar ;
MESSAGE TXT_GOTO_PREVIOUS_PAGE ;
TOOLTIP Strtran(TXT_PREVIOUS,"&","") NOBORDER
DEFINE BUTTON RESOURCE "Next" OF oBar ;
MESSAGE TXT_GOTO_NEXT_PAGE ;
TOOLTIP Strtran(TXT_NEXT,"&","") NOBORDER
DEFINE BUTTON RESOURCE "Bottom" OF oBar ;
MESSAGE TXT_GOTO_LAST_PAGE ;
TOOLTIP Strtran(TXT_LAST,"&","") NOBORDER
DEFINE BUTTON oZoom RESOURCE "Zoom" OF oBar GROUP ;
MESSAGE TXT_ZOOM_THE_PREVIEW ;
TOOLTIP Strtran(TXT_ZOOM,"&","") NOBORDER
DEFINE BUTTON oTwoPages RESOURCE "Two_Pages" OF oBar ;
MESSAGE TXT_PREVIEW_ON_TWO_PAGES ;
TOOLTIP Strtran(TXT_TWOPAGES,"&","") NOBORDER
DEFINE BUTTON RESOURCE "Printer" OF oBar GROUP ;
MESSAGE TXT_PRINT_CURRENT_PAGE ;
TOOLTIP Strtran(TXT_PRINT,"&","") NOBORDER
DEFINE BUTTON RESOURCE "Exit" OF oBar GROUP ;
MESSAGE TXT_EXIT_PREVIEW ;
ACTION oWnd:End() ;
TOOLTIP Strtran(TXT_EXIT,"&","") NOBORDER
else
DEFINE BUTTON RESOURCE "Top" OF oBar ;
MESSAGE TXT_GOTO_FIRST_PAGE ;
TOOLTIP Strtran(TXT_FIRST,"&","")
DEFINE BUTTON RESOURCE "Previous" OF oBar ;
MESSAGE TXT_GOTO_PREVIOUS_PAGE ;
TOOLTIP Strtran(TXT_PREVIOUS,"&","")
DEFINE BUTTON RESOURCE "Next" OF oBar ;
MESSAGE TXT_GOTO_NEXT_PAGE ;
TOOLTIP Strtran(TXT_NEXT,"&","")
DEFINE BUTTON RESOURCE "Bottom" OF oBar ;
MESSAGE TXT_GOTO_LAST_PAGE ;
TOOLTIP Strtran(TXT_LAST,"&","")
DEFINE BUTTON oZoom RESOURCE "Zoom" OF oBar GROUP ;
MESSAGE TXT_ZOOM_THE_PREVIEW ;
TOOLTIP Strtran(TXT_ZOOM,"&","")
DEFINE BUTTON oTwoPages RESOURCE "Two_Pages" OF oBar ;
MESSAGE TXT_PREVIEW_ON_TWO_PAGES ;
TOOLTIP Strtran(TXT_TWOPAGES,"&","")
DEFINE BUTTON RESOURCE "Printer" OF oBar GROUP ;
MESSAGE TXT_PRINT_CURRENT_PAGE ;
TOOLTIP Strtran(TXT_PRINT,"&","")
DEFINE BUTTON RESOURCE "Exit" OF oBar GROUP ;
MESSAGE TXT_EXIT_PREVIEW ;
ACTION oWnd:End() ;
TOOLTIP Strtran(TXT_EXIT,"&","")
endif
AEval( oBar:aControls, { | o | o:oCursor := oHand } )
endif
#ifdef __CLIPPER__
SET MESSAGE OF oWnd TO TXT_PREVIEW CENTERED ;
NOINSET CLOCK DATE KEYBOARD
#else
DEFINE STATUSBAR OF oWnd PROMPT " " + TXT_PREVIEW // CLOCK
#endif
oMeta1 := TMetaFile():New( 0, 0, 0, 0,;
aFiles[ 1 ],;
oWnd,;
CLR_BLACK,;
CLR_WHITE,;
)
oMeta1:oCursor := oCursor
nPage := 1
nZFactor := 1
lTwoPages := .F.
lZoom := .F.
@ 7, 275 SAY oSay PROMPT TXT_FACTOR ;
SIZE 60, 15 PIXEL OF oBar FONT oFont
if IsAppThemed_ed()
oSay:SetBrush( TBrush():New( "NULL" ) )
endif
// PDF
@ 7, 278 SAY oSay2 PROMPT "Factor:" ;
SIZE 180, 15 PIXEL OF oBar FONT oFont
@ 3, 325 COMBOBOX oFactor VAR nZFactor ;
ITEMS {"1","2","3","4","5","6","7","8","9"} ;
OF oBar FONT oFont PIXEL SIZE 35,200
if Len( aFiles ) > 1
@ 7, 370 SAY oPAGE PROMPT TXT_PAGENUM+ltrim(str(nPage,4,0)) + " / " + ;
ltrim(str(len(aFiles))) ;
SIZE 180, 15 PIXEL OF oBar FONT oFont
else
@ 7, 370 SAY oPAGE PROMPT TXT_PAGENUM+ltrim(str(nPage,4,0)) ;
SIZE 180, 15 PIXEL OF oBar FONT oFont
endif
// modi mcn para seleccionar impresora desde el preview
@ 7, 540 SAY oSay2 PROMPT "Impresora:" ;
SIZE 180, 15 PIXEL OF oBar FONT oFont
@ 3, 610 COMBOBOX oCbx VAR cCbx ;
PROMPTS aImpre ;
OF oBar FONT oFont PIXEL SIZE 150,350
if IsAppThemed_ed()
FixSays( oBar:hWnd )
endif
#ifndef __XPP__
oFactor:Set3dLook()
#endif
oWnd:cargo := oDevice
WndCenter( oWnd:hWnd )
SysRefresh()
SetResources(hOldRes)
ACTIVATE WINDOW oWnd ;
MAXIMIZED
/* ;
VALID (oWnd:oIcon := nil ,;
oFont:End() ,;
oMeta1:End() ,;
oMeta2:End() ,;
oDevice:End() ,;
oHand:End() ,;
oWnd := nil ,;
If( IsAppThemed_ed(), oImageList:End(),),;
lExit := .T. ,;
.T.)
StopUntil( {|| lExit} )
*/
if oDevice:lPrvModal .and. oWndMain != nil
oWndMain:Show()
endif
return (nil)
//----------------------------------------------------------------------------//
function IsAppThemed_ed()
return .t.