how can i create a small preview in a dialog?
i need it to calibrate the lottery slips
#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
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.
oPrn:FillRect( aRect, oBrush )
#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
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.
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 44 guests