FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Small Preview of report
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Small Preview of report
Posted: Fri Jun 06, 2014 07:09 PM
I need a small Preview of report to insert on small dialog ...to show to use how the report do.
Exit a method or a sample test ?

I'm thinking something of this ...



at right the button for Preview or print
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 06:46 AM

Silvio,

The first idea that comes to my mind is that you create a copy of rpreview.prg and then modify it to suit your needs:

Change the main windows into a dialog, etc.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 06:49 AM

Silvio,

In METHOD BuildListView() CLASS TPreview we create the thumbnails that are painted on the left side of the preview.

Maybe you could use them so you could simplify it very much.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 07:51 AM
Antonio,While I'm waiting your idea I made this :
( from Old Rpreview)




only I have one problem :
1. if the Report have many pages I cannot scroll the pages
I insert the metafiles on a dialog ...perhaps I need a object to insert on dialog and thi object must be the scroll
Question ...If you I can use Tpanel class as this object ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 07:59 AM

Silvio,

Thats why I told you to use a ListView as we use from the left side of the preview, that way you could move up and down and see other report pages.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 08:06 AM
With the idea of BuildListView() it is easy but I tried but I not understand how make small the listview

I try this :

Code (fw): Select all Collapse
   Function PanelView(oDevice,oDlgMiniPrint)

   local nSizeH, nSizeV, oBmp, n, aPrompts := {}
   local oImageListPages

   if oDevice:nHorzRes() > oDevice:nVertRes()
     nSizeH = 100
     nSizeV = 80
   else
     nSizeH = 80
     nSizeV = 100
   endif

   oBmp = TBitmap():Define()
   oBmp:nWidth:=100


   oImageListPages = TImageList():New( nSizeH, nSizeV )

   for n := 1 to Len( oDevice:aMeta )
      oBmp:hBitmap := PageBitmap( oDevice:aMeta[ n ], nSizeH, nSizeV )
      oImageListPages:Add( oBmp )
      Aadd( aPrompts, AllTrim( Str( n ) ) )
   NEXT

  oLvw = TListView():New( 2, 2, aPrompts, , oDlgMiniPrint, CLR_WHITE,;
               CLR_GRAY,.t., .f., 100, 100,;
                )

   oLvw:SetImageList( oImageListPages )


return nil




but it run this :



Any help please ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 08:15 AM

Silvio,

You have to check what images sizes a standard ListView control supports and how to change it.

Look for the ListView Microsoft docs.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 08:27 AM

NOOOO it run ok .... I made a mistake ... there is a object ( tpanel) on dialog ahahahahaha :))) sorrryyyy

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 10:44 AM
This the code...on working

do you like it ?

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "report.ch"
#include "constant.ch"

request DBFCDX

STATIC oReport
STATIC oLvw

//---------------------------------------------------------------------------//
//  Test MiniPreview
//  Falconi Silvio june 2014
//---------------------------------------------------------------------------//


Function Main()

     USE TEST NEW VIA "DBFCDX"

     REPORT oReport TITLE  "*** My First Report ***" PREVIEW

     COLUMN TITLE "St"         DATA Test->State
     COLUMN TITLE "First Name" DATA Test->First
     COLUMN TITLE "   Salary"  DATA Test->Salary

     END REPORT

     oReport:CellView()

     ACTIVATE REPORT oReport

     CLOSE TEST

     RETURN NIL



Function RPreview( oDevice, oReport)
            Local oDlgMiniPrint,oFldMiniPrint
            Local nBottom   := 30
            Local nRight    := 60.2
            Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
            Local nHeight := nBottom * DLG_CHARPIX_H

            Local oBtnPreview
            Local oBtnPrint
            Local oBtnExit
            Local oBtnEmail
            Local oBtnPdf
            Local oBtnHelp
            Local oFont := TFont():New( GetDefaultFontName(), 0, GetDefaultFontHeight(),, )
            Local oPanelPreview
            Local oSay

            DEFINE BRUSH oBrush COLOR CLR_HGRAY

            DEFINE DIALOG oDlgMiniPrint       ;
            TITLE "Mini Print"    ;
            SIZE nWidth, nHeight  PIXEL


            @ 0,0.5 Say oSay Prompt oDevice:cDocument OF oDlgMiniPrint  SIZE 230,15 COLOR CLR_HGRAY,CLR_WHITE



           oPanelPreview:=TPanel():New(20, 0, 200, 160, oDlgMiniPrint)
           oPanelPreview:SetBrush( oBrush )



           @ 20,160 FOLDER oFldMiniPrint Prompt "Stand.","Pers." PIXEL;
                               SIZE 78, oPanelPreview:nbottom-110 OF oDlgMiniPrint


             @ 110, 160 BUTTON oBtnPreview PROMPT "&Anteprima di Stampa" OF oDlgMiniPrint SIZE 77, 10;
                              PIXEL FONT oFont DEFAULT  ACTION (Preview_Class(oDevice, oReport),oDlgMiniPrint:End())

             @ 122, 160 BUTTON oBtnPreview PROMPT "&Uscita" OF oDlgMiniPrint SIZE 77, 10;
                              PIXEL FONT oFont DEFAULT  ACTION (oDlgMiniPrint:End())




             ACTIVATE DIALOG oDlgMiniPrint   CENTERED ;
            ON INIT  PanelView(oDevice,oPanelPreview)

            return nil







//--------------------------------------------------------------------//
   Function Preview_Class(oDevice, oReport)
           local oPreview := TPreview():New( oDevice, oReport )
                 oDevice:oPreview := oPreview
                 oPreview:Activate()
            return nil

//--------------------------------------------------------------------//


   Function PanelView(oDevice,oPanelPreview)

   local nSizeH, nSizeV, oBmp, n, aPrompts := {}
   local oImageListPages,nPage:=1

    if oDevice:nHorzRes() > oDevice:nVertRes()
     nSizeH = 250
     nSizeV = 250
   else
     nSizeH = 230
     nSizeV = 340
   endif


   oBmp = TBitmap():Define()

   oImageListPages = TImageList():New( nSizeH, nSizeV )

   for n := 1 to Len( oDevice:aMeta )
      oBmp:hBitmap := PageBitmap( oDevice:aMeta[ n ], nSizeH, nSizeV )
      oImageListPages:Add( oBmp )
      Aadd( aPrompts, AllTrim( Str( n ) ) )
   NEXT

   oLvw := TListView():New( 5, 5, aPrompts,{ | nPage | Preview_Class_Page(oDevice, oReport,nPage) } , oPanelPreview, ,;
            , .T., , oPanelPreview:nWidth-10,oPanelPreview:nBottom+155, "MiniPreview" )

   oLvw:setcolor(,CLR_GRAY)

   oLvw:SetImageList( oImageListPages )


  return nil

//--------------------------------------------------------------------//
  Function Preview_Class_Page(oDevice, oReport,nPage)
           local oPreview := TPreview():New( oDevice, oReport )
           oDevice:oPreview := oPreview
           oPreview:GoPage( nPage )
           oPreview:Activate()
            return nil

//------------------------------------------------------------------------//


 static function PageBitmap( cEMF, nWidth, nHeight )

   local hDC1 := GetDC( GetDesktopWindow() )
   local hDC2 := CreateCompatibleDC( hDC1 )
   local hBmp := CreateCompatibleBitmap( hDC1, nWidth, nHeight )
   local hOldBmp := SelectObject( hDC2, hBmp )
   local hEMF := GetEnhMetaFile( cEmf )

   Rectangle( hDC2, 0, 0, nHeight, nWidth )

   XPlayEnhMetaFile( hDC2, hEMF, 0, 0, nHeight, nWidth )
   CloseEnhMetafile( hEMF )

   SelectObject( hDC2, hOldBmp )


   DeleteDC( hDC2 )
   ReleaseDC( hDC1 )

return hBmp

//--------------------------------------------------------------------//







only when I click on first oage not go to preview ( if i click on second page it go to page preview right)

do you have some suggestions ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 12:34 PM
Silvio,

Very good, you are getting better and better :-)

only when I click on first oage not go to preview ( if i click on second page it go to page preview right)


Sorry, I don't understand what you mean
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Small Preview of report
Posted: Sat Jun 07, 2014 01:47 PM

Please compile it .. you 'll see two pages on listview
if you click on secon page you can go to preview (tpreview)
If you click on first page you cannot go to preview of first page

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion