IF ::oDevice:lPrvModal
StopUntil( { || ::lExit } )
ENDIF
*--------------------------------------------------------------------------------------
function AddExportBtns( oPreview, oBar, oReport )
local aRet
Local cpdfName
cPdfName := alltrim( GetTempDir() + ;
AllTrim( StrTran( StrTran( oPreview:oDevice:cDocument, "/", "-" ), " ", "_" ) ) ) + ".pdf"
aRet := { { "Excel", "Export to Excel",;
{|| oReport:SaveAs( "EXCEL" ) }, "Excel" },;
{ "Pdf", "Export to Pdf Document",;
{ || BuildPdf( oPreview:oDevice:aMeta, cpdfName, .f., .t. ) }, "Pdf" } }
Return aRet
*--------------------------------------------------------------------------------------
METHOD New( aTitle, aHead, aFoot, aFont, lSummary, cRptFile, ;
cResName, lPrinter, lScreen, cFile, oDevice, ;
cName, cTFmt, cHFmt, cFFmt ) CLASS TMReport
Local uReturn := Super:New( aTitle, aHead, aFoot, aFont, lSummary, cRptFile, ;
cResName, lPrinter, lScreen, cFile, oDevice, ;
cName, cTFmt, cHFmt, cFFmt )
If Empty( uReturn ) // Error
Return Nil
EndIf
//rPrevUserBtns is a new function in rPreview.prg
RPrevUserBtns( { |oPreview, oBar| addExportBtns( oPreview, oBar, Self ) } )
::bPreview := { |oDevice, oRpt| rPreview( oDevice, oRpt ) }
Return Self
//----------------------------------------------------------------------------//
METHOD BuildButtonBar() CLASS TPreview
local oThis := Self
local oBtn
local oReBar, oBar, oWndMain
local l97Look := ::oWndMain != nil .and. ::oWndMain:oBar != nil .and. ;
Len( ::oWndMain:oBar:aControls ) > 0 .and. ;
::oWndMain:oBar:aControls[ 1 ]:l97Look
local aPreviewBtns, aBtn
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 !empty( bUserBtns )
aPreviewBtns := Eval( bUserBtns, Self, oBar )
endif
oBar := TBar():New( ::oWnd, 50, 60, .F.,,, .T. )
TBtnBmp():NewBar( "Top",,,,, {|| ::TopPage() }, .F., oBar, .F.,,;
"First Page", .F.,,,, "First",,,,,,,,, .F. )
TBtnBmp():NewBar( "Previous",,,,, { || ::PrevPage() }, .F., oBar, .F.,,;
"Prev Page", .F.,,,, "Prev",,,,,,,,, .F. )
TBtnBmp():NewBar( "Next",,,,, {|| ::NextPage()}, .F., oBar, .F.,,;
"Next Page", .F.,,,, "Next",,,,,,,,, .F. )
TBtnBmp():NewBar( "Bottom",,,,, {|| ::BottomPage() }, .F., oBar, .F.,,;
"Last Page", .F.,,,, "Last",,,,,,,,, .F. )
TBtnBmp():NewBar( "Zoom",,,,, {|| ::zoom() }, .T., oBar, .F.,, ;
"Zoom", .F.,,,, "Zoom",,,,,,,,, .F. )
TBtnBmp():NewBar( "Two_Pages",,,,, {||::TwoPages() }, .F., oBar, .F.,,;
"View two pages side by side", .F.,,,,"Two Pages",,,,,,,,, .F. )
TBtnBmp():NewBar( "Printer",,,,, {|| ::PrintPage() }, .F., oBar, .F.,, ;
"Print", .F.,,,, "Print",,,,,,,,, .F. )
if aPreviewBtns != Nil .and. valtype( aPreviewBtns ) = "A" .and. ;
len( aPreviewBtns ) > 0
FOR EACH aBtn IN aPreviewBtns
TBtnBmp():NewBar( aBtn[ 1 ],,,,, aBtn[ 3 ], .F., oBar, .F.,, ;
aBtn[ 2 ], .F.,,,, aBtn[ 4 ],,,,,,,,, .F. )
NEXT
endif
oBtn := TBtnBmp():NewBar( "Exit",,,,, {|| oThis:oWnd:end() }, .F., oBar, .F.,, ;
"Exit", .F.,,,, "Exit",,,,,,,,, .F. )
@ 7, oBtn:nRight + 5 SAY ::oSay PROMPT "Factor:" SIZE 45, 15 PIXEL OF oBar FONT ::oFont
::oSay:lTransparent = .T.
@ 3, oBtn:nRight + 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 Len( ::oDevice:aMeta ) > 1
@ 7, oBtn:nRight + 95 ;
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, oBtn:nRight + 95 ;
SAY ::oPage PROMPT TXT_PAGENUM + LTrim( Str( ::nPage, 4, 0 ) ) ;
SIZE 180, 15 PIXEL OF oBar FONT ::oFont
endif
::oPage:lTransparent = .T.
// AEval( oBar:aControls, { | o | o:oCursor := ::oHand } )
return nil
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 ,;
::lExit := .T. ,;
.T. )
if ::oDevice:lPrvModal
StopUntil( { || ::lExit } ) //<------ Look here.
endif
return nil
DO WHILE !Eval( bBlock ) .and. WndMain() != NIL .and. IsWindow( WndMain():hWnd )
if ::hWnd != 0 .and. GetWndApp() == ::hWnd
PostQuitMessage( 0 )
Sysrefresh()
QUIT
endif
James Bott wrote:Reinaldo,
You could try, when defining the report, something like this:
wndMain():bValid := {|| oRpt:lEnd := .t., .t.}
This should end the preview when the main window is closed.
Regards,
James
METHOD Activate() CLASS TPreview
local bValidMain := If( ::oWndMain == nil, nil, ::oWndMain:bValid )
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() ,;
If( ::oWndMain == nil,, ::oWndMain:bValid := bValidMain ),;
::oWnd := nil ,;
If( IsAppThemed() .and. ! l2007, ::oImageList:End(),),;
::lExit := .T. ,;
.T. )
if ::oWndMain != nil
if bValidMain == nil
::oWndMain:bValid := { || ::lExit := .t. }
else
::oWndMain:bValid := { || If( Eval( bValidMain ), ::lExit := .t., .f. ) }
endif
endif
if ::oDevice:lPrvModal
StopUntil( { || ::lExit } )
endif
return nil
//----------------------------------------------------------------------------//
James Bott wrote:wndMain():bValid := {|| oRpt:lEnd := .t., .t.}
wndMain():bValid := {|| oRpt:lEnd := .t.}
if ::oDevice:lPrvModal
StopUntil( { || ::lExit .or. WndMain() == Nil .or. !IsWindow( WndMain():hWnd ) } )
endif
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 51 guests