Small RPreview

Small RPreview

Postby Silvio.Falconi » Tue Oct 01, 2024 12:01 pm

how can i create a small preview in a dialog?

i need it to calibrate the lottery slips
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small RPreview

Postby nageswaragunupudi » Tue Oct 01, 2024 3:41 pm

This is a small sample program.
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn

   SetCustomPrintPreview( { |o| DlgPreview( o ) } )

   PRINT oPrn PREVIEW
   oPrn:SetPage( 11 )

   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\olga1.jpg" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE
   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\sea.bmp" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE

   ENDPRINT

   SetCustomPrintPreview( nil )

return nil


function DlgPreview( oPrn )

   local oDlg, oBar, oImage, nPage := 1
   local lBar  := Len( oPrn:aMeta ) > 1

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL RESIZABLE
   if lBar
      DEFINE BUTTONBAR oBar OF oDlg SIZE 32,40 2010 NOBORDER
   endif

   @ If( lBar, 60, 20 ),20 XIMAGE oImage SOURCE oPrn:aMeta[ 1 ] SIZE -20,-20 OF oDlg

   if lBar
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "top2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ nPage := 1 ] )
      DEFINE BUTTON OF oBar RESOURCE FwBitmap( "previous2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ --nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "next2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION oImage:SetSource( oPrn:aMeta[ ++nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "bottom2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION ( oImage:SetSource( oPrn:aMeta[ nPage := Len( oPrn:aMeta ) ] ) )
   endif

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


Please modify the size of the dialog as per your needs.

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Small RPreview

Postby Silvio.Falconi » Tue Oct 01, 2024 4:27 pm

nageswaragunupudi wrote:This is a small sample program.
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn

   SetCustomPrintPreview( { |o| DlgPreview( o ) } )

   PRINT oPrn PREVIEW
   oPrn:SetPage( 11 )

   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\olga1.jpg" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE
   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\sea.bmp" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE

   ENDPRINT

   SetCustomPrintPreview( nil )

return nil


function DlgPreview( oPrn )

   local oDlg, oBar, oImage, nPage := 1
   local lBar  := Len( oPrn:aMeta ) > 1

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL RESIZABLE
   if lBar
      DEFINE BUTTONBAR oBar OF oDlg SIZE 32,40 2010 NOBORDER
   endif

   @ If( lBar, 60, 20 ),20 XIMAGE oImage SOURCE oPrn:aMeta[ 1 ] SIZE -20,-20 OF oDlg

   if lBar
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "top2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ nPage := 1 ] )
      DEFINE BUTTON OF oBar RESOURCE FwBitmap( "previous2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ --nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "next2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION oImage:SetSource( oPrn:aMeta[ ++nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "bottom2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION ( oImage:SetSource( oPrn:aMeta[ nPage := Len( oPrn:aMeta ) ] ) )
   endif

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


Please modify the size of the dialog as per your needs.

Image




sorry Nageswarao maybe I didn't explain myself well, I need a dialog that has a printed coupon on one side and an xbrowse with the data on the other, in the xbrowse there is the data i.e. the coordinates to put a pixel above a position, I need it to calibrate the Italian lottery coupons

I'll draw you a picture of how I would like to make it


Image

on oldest app I use a procedure to insert pixel into coupon

Code: Select all  Expand view
oPrn:FillRect( aRect, oBrush )


but I see it if is right only when I go to rpreview as you can see here

Image

I thinked to create something of visual , the final use insert data on xbrowse and the procedure put the pixel on image

then I can save the coordinates on archive and printer the coupons
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small RPreview

Postby Silvio.Falconi » Tue Oct 01, 2024 6:48 pm

Nages this is my Idea

Image


Code: Select all  Expand view
#include "FiveWin.ch"
#include "Constant.ch"

Function test()
//dialog
local oDlg, oBrw, oFont, oBold, oCoupon
local nBottom   := 34
local nRight    := 75
local nWidth    := Max( nRight * DLG_CHARPIX_W, 180 )
local nHeight   := nBottom * DLG_CHARPIX_H
local aData     := {{"numero 1","0.9","27.17"}}
local cTicket:="ticket.jpg"
local oRowAdd,oRowEra

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-10
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12  BOLD


   DEFINE DIALOG oDlg SIZE  nWidth, nHeight  ;
   PIXEL TRUEPIXEL FONT oFont    ;  //RESIZABLE   FONT oFont
   TiTle "Taratura schedina"


//Image

   @ 10, 0 XIMAGE oCoupon SIZE 250, 500 OF oDlg SOURCE cTicket  NOBORDER
                oCoupon:bRClicked  := { || NIL }
                oCoupon:nUserControl :=0

//xbrowse table
    @ 10, 280 XBROWSE  oBrw OF oDlg ;
      SIZE 300,400 PIXEL NOBORDER


    oBrw:SetArray(aData)

        oBrw:aCols[1]:cHeader  := i18n("Descrizione")
        oBrw:aCols[1]:nWidth   := 110
        oBrw:aCols[2]:cHeader  := i18n("X")
        oBrw:aCols[2]:nWidth   := 110
        oBrw:aCols[3]:cHeader  := i18n("Y")
        oBrw:aCols[3]:nWidth   := 110

   oBrw:nMarqueeStyle       :=MARQSTYLE_HIGHLWIN7 //MARQSTYLE_HIGHLROW
   oBrw:nColDividerStyle    := LINESTYLE_LIGHTGRAY
   oBrw:lColDividerComplete := .t.
   oBrw:lRecordSelector     := .f.
   oBrw:lHScroll             := .f.
   oBrw:nHeaderHeight       := 20
   oBrw:nRowHeight          := 20
   oBrw:SetStyle( 2018 )

     oBrw:CreateFromCode()


      @ 100,10 BTNBMP oRowAdd PROMPT  "Aggiungi riga"  of oDlg ;
      SIZE 100,22 FLAT NOROUND;
       FILENAME ".\bitmaps\aggiungi.png" LEFT ;
      ACTION  nil //AddRow( oBrw ,@nRows,@nCols,aGet)


      @ 100,10 BTNBMP oRowEra PROMPT "Elimina riga"  of oDlg ;
      SIZE 100,22 FLAT NOROUND;
       FILENAME ".\bitmaps\elimina.png"   LEFT ;
      ACTION nil // DeleteRow( oBrw,@nRows,@nCols,aGet )



        oDlg:bResized := <||
               local oRect := oDlg:GetCliRect()
                    oRowAdd:nTop     := oBrw:nbottom +10
                    oRowAdd:nLeft    := oRect:nRight - 230

                    oRowEra:nTop     := oBrw:nbottom +10
                    oRowEra:nLeft    := oRect:nRight - 130

              RETURN NIL
                       >
           ACTIVATE DIALOG oDlg CENTERED;
                      ON INIT (Eval(oDlg:bResized))

   RELEASE FONT oFont, oBold
RETURN NIL





 


Now I don't know how I have to draw a black circle for each number and at the same time have the exact coordinates for when I send to the printer
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: Small RPreview

Postby Silvio.Falconi » Fri Oct 11, 2024 9:44 am

nageswaragunupudi wrote:This is a small sample program.
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oPrn

   SetCustomPrintPreview( { |o| DlgPreview( o ) } )

   PRINT oPrn PREVIEW
   oPrn:SetPage( 11 )

   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\olga1.jpg" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE
   PAGE
      @ 1,1 PRINT TO oPrn IMAGE "..\bitmaps\sea.bmp" ;
         SIZE 9,29 CM ALIGN "T"
   ENDPAGE

   ENDPRINT

   SetCustomPrintPreview( nil )

return nil


function DlgPreview( oPrn )

   local oDlg, oBar, oImage, nPage := 1
   local lBar  := Len( oPrn:aMeta ) > 1

   DEFINE DIALOG oDlg SIZE 300,400 PIXEL TRUEPIXEL RESIZABLE
   if lBar
      DEFINE BUTTONBAR oBar OF oDlg SIZE 32,40 2010 NOBORDER
   endif

   @ If( lBar, 60, 20 ),20 XIMAGE oImage SOURCE oPrn:aMeta[ 1 ] SIZE -20,-20 OF oDlg

   if lBar
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "top2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ nPage := 1 ] )
      DEFINE BUTTON OF oBar RESOURCE FwBitmap( "previous2" ) ;
         WHEN nPage > 1 ;
         ACTION oImage:SetSource( oPrn:aMeta[ --nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "next2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION oImage:SetSource( oPrn:aMeta[ ++nPage ] )
      DEFINE BUTTON OF oBar RESOURCE FWBitmap( "bottom2" ) ;
         WHEN nPage < Len( oPrn:aMeta ) ;
         ACTION ( oImage:SetSource( oPrn:aMeta[ nPage := Len( oPrn:aMeta ) ] ) )
   endif

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


Please modify the size of the dialog as per your needs.

Image







Nages I tested your script

When I go to Small Rpreview I have this

Image

when I size to big the dialog I have this

Image

the image is printed at center , then the image is printed on center or it printed on left ?


problem I not see the buttonbar because I have only a page ok but I wish insert two buttons one for exit and one for print
how I can make ?


If I use

@ nTop + nMargineSuperiore,nLeft + nMargineSinistro PRINT TO oPrn IMAGE cFile ;
SIZE nRight, nBottom CM ALIGN "T"

and I have this result

Image



the image is not printed correctly in the position, I use this function where I convert the measurements from cm to Pixel

Code: Select all  Expand view
FUNCTION PrintImage(nTop, nLeft, nRight, nBottom, cFile, nMargineSuperiore, nMargineSinistro, oPrn)
oPrn:Cmtr2Pix(@nTop, @nLeft)
   oPrn:Cmtr2Pix(@nBottom, @nRight)
   oPrn:SayImage(nTop + nMargineSuperiore, nLeft + nMargineSinistro, cFile, nRight, nBottom)
return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests