#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"
#include "report.ch"
function Main()
local oDlg, oBrw, oFont
oDbf:=Tdatabase():Open(,"customer" ,"DBFCDX", .t.)
oDbf:setorder(1)
oDbf:Gotop()
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
DEFINE DIALOG oDlg SIZE 640,440 PIXEL ;
FONT oFont TITLE 'XBrowse test print column'
@ 10, 10 XBROWSE oBrw OF oDlg SIZE 300, 160 PIXEL ;
AUTOCOLS ALIAS oDbf NOBORDER
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLWIN7
oBrw:SetMultiSelectCol()
oBrw:CreateFromCode()
@ 200, 10 BUTTON "PRINT" SIZE 45,12 PIXEL OF oDlg ;
ACTION OptionPrint(oBrw)
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//--------------------------------------------------------------------//
function OptionPrint( oBrowse)
local aCols := {}
local oDlgOptions,oBarOption,oIcon
local oFont,oBold
local oBrw
local cTitle:="Columns to Print"
local nBottom := 20
local nRight := 40
local nWd := Max( nRight * DLG_CHARPIX_W, 180 )
local nHt := nBottom * DLG_CHARPIX_H
* ORIGINAL
*AEval( oBrowse:aCols, { |o,i| AAdd( aCols, { o:cHeader,i, !o:lHide } ) } )
// TOGGLE COLUMN FOR :SetMultiSelectCol()
AEval( oBrowse:aCols, { |o,i| AAdd( aCols, { If(empty(o:cHeader),"Col-" + cValToChar( i ),o:cHeader),;
i, !o:lHide } ) } )
DEFINE ICON oIcon RESOURCE "ICON1"
DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
DEFINE FONT oBold NAME 'Tahoma' SIZE 0, -14 BOLD
DEFINE DIALOG oDlgOptions SIZE nWd, nHt PIXEL TRUEPIXEL ;
TITLE cTitle COLOR CLR_BLACK,RGB( 245,245,235) ICON oIcon
oDlgOptions:lHelpIcon := .F.
oDlgOptions:nStyle := nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION,WS_SYSMENU,WS_MINIMIZEBOX )
DEFINE BUTTONBAR oBarOptions OF oDlgOptions SIZE 64,70 2015 BOTTOM
DEFINE BUTTON OF oBarOptions PROMPT "Annulla" ;
FILE "DLG_NO" ;
ACTION ( oDlgOptions:end( IDCANCEL ) )
DEFINE BUTTON OF oBarOptions PROMPT "Conferma" ;
RESOURCE "DLG_OK" BTNRIGHT;
ACTION ( aCols := {}, ;
AEval( oBrw:aArrayData, { |a| If( a[ 3 ], AAdd( aCols, oBrowse:aCols[ a[ 2 ] ] ), nil ) } ), ;
oDlgOptions:end( IDOK ) )
oBarOptions:bClrGrad := { | lPressed | If( ! lPressed,;
{ { 1, RGB( 250,250,245), RGB( 250,250,245)} },;
{ { 1, RGB( 245,245,235), RGB( 245,245,235)} } ) }
@ 10,10 XBROWSE oBrw SIZE -10,-110 PIXEL OF oDlgOptions ;
DATASOURCE aCols ;
COLUMNS 1,2,3 ;
HEADERS "Column","No","" ;
COLSIZES 100, 40, 40 ;
NOBORDER FONT oFONT
WITH OBJECT oBrw
:lHScroll:=.f.
:lDrawBorder := .t.
WITH OBJECT :aCols[ 3]
:SetCheck(, .t. )
* :nHeadBmpNo := 2
END
:CreateFromCode()
END
oDlgOptions:bResized := <||
local oRect := oDlgOptions:GetCliRect()
oBrw:setfocus()
return nil
>
ACTIVATE DIALOG oDlgOptions CENTERED ;
ON INIT (oDlgOptions:resize(), ;
ChangeButtons( oBarOptions ))
RELEASE oFont,oBold
oBrowse:refresh()
IF oDlgOptions:nresult == IDOK
//return aCols
Reporte(oBrowse,aCols)
ENDIF
RETURN NIL
//------------------------------------------------------------------------//
function ChangeButtons( oBar )
AEval( oBar:aControls, { | oCtrl | oCtrl:nTop += 4, oCtrl:nHeight -= 4 } )
return .T.
//-------------------------------------------------------------------------//
STATIC FUNCTION Reporte(oBrw,aColumns)
local oRep, oFont, oFont1, oFontCopy
DEFINE FONT oFont NAME "ARIAL" SIZE 0,-9
DEFINE FONT oFont1 NAME "CALIBRI" SIZE 0,-9 BOLD
oBrw:GoTop()
REPORT oRep TITLE "Customers";
FONT oFont,oFont1;
HEADER "Report of Customers " CENTER ;
FOOTER "Hoja:" + STR(oRep:npage,3) ,"Fecha:"+DTOC(DATE()) CENTER;
PREVIEW CAPTION "Customers"
COLUMN TITLE "First" DATA oBrw:oDbf:first SIZE 15 FONT 1 SHADOW
COLUMN TITLE "Last" DATA oBrw:oDbf:last SIZE 15 FONT 1 SHADOW
COLUMN TITLE "City" DATA oBrw:oDbf:city SIZE 10 FONT 1 SHADOW
COLUMN TITLE "State" DATA oBrw:oDbf:state SIZE 06 FONT 2 SHADOW
oRep:oShdBrush := TBrush():New(,nRgb(219,229,241))
oRep:oTitle:aFont[1] := {|| 2 }
oRep:bInit := {|| oBrw:oDbf:GoTop()}
oRep:bSkip := {|| (IF(!oBrw:oDbf:Eof(),oBrw:oDbf:Skip(),nil),IF(oRep:nCounter % 2 =1 , oRep:lShadow :=.f.,oRep:lShadow :=.t.))}
END REPORT
ACTIVATE REPORT oRep WHILE !oBrw:oDbf:Eof() ;
ON ENDPAGE ( oRep:oTitle := TrLine():New({}),;
oRep:nTitleRow := oRep:oHeader:nHeight + oRep:nTopMargin )
RETURN nil
//-------------------------------------------------------------------------------------//