VF9实现滚动式打印预览程序Word格式.docx

上传人:b****4 文档编号:6916454 上传时间:2023-05-07 格式:DOCX 页数:27 大小:22.37KB
下载 相关 举报
VF9实现滚动式打印预览程序Word格式.docx_第1页
第1页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第2页
第2页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第3页
第3页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第4页
第4页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第5页
第5页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第6页
第6页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第7页
第7页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第8页
第8页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第9页
第9页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第10页
第10页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第11页
第11页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第12页
第12页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第13页
第13页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第14页
第14页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第15页
第15页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第16页
第16页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第17页
第17页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第18页
第18页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第19页
第19页 / 共27页
VF9实现滚动式打印预览程序Word格式.docx_第20页
第20页 / 共27页
亲,该文档总共27页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

VF9实现滚动式打印预览程序Word格式.docx

《VF9实现滚动式打印预览程序Word格式.docx》由会员分享,可在线阅读,更多相关《VF9实现滚动式打印预览程序Word格式.docx(27页珍藏版)》请在冰点文库上搜索。

VF9实现滚动式打印预览程序Word格式.docx

ReportForm(RptName) 

ObjectoListenerNowait&

FOR&

rptfor=&

rptforval

*--报表预览窗

DefineClassReportFormAsForm

caption="

打印预览"

AutoCenter=.T.

WindowState=2

BorderStyle=0

TitleBar=0

WindowType=1

BackColor=Rgb(65,65,65)

showwindow=1

DataSession=1

oListener=.Null.

nCurrentPage=1

nPageHeight=100

nPageWidth=100

ScrollBars=3

vscrollsmallchange=10

AllowOutput=.F.

oTools=.Null.

oGotoPage= 

.Null.

oPrint= 

*printbl=0

oshpPreview=.null.

AddObjectshpPreview1 

AsmyPreview 

With;

Top=10,;

Left=10,;

Width= 

300,;

Height= 

300

ProcedureInit

*-隐藏顶层表单的工具栏(可根据需要选用)

IFotoolbarbl=.t.&

当otoolbarbl为真时(otoolbarbl全局变量返回工具栏的显示与否)

HIDEWINDOW常用&

隐藏名为“常用”的工具栏

SETMARKOFBAR2OF显示vTO.f.&

去除“显示V”菜单中菜单编号为2的菜单项(用于显示或隐藏工具栏)前的勾

otoolbarbl=.f.

ENDIF

******************************************

DoDefault()

WithThisAsForm

.oTools=Createobject([frxpreviewtoolbar])

.oGotoPage 

=Createobject([frxgotopageform])

.oPrint 

=Createobject([frxPrintForm])

.oshpPreview=CREATEOBJECT([myPreview])

With.oTools

.Show()

Bindevent(This.oTools,[CboZooMInteractiveChange],This,[CboZooMInteractiveChange])

Bindevent(.cmdClose,[Click],This,[cmdCloseClick])

Bindevent(.cmdgotopage,[Click],This,[ActionGotoPage])

Bindevent(.cmdprint,[Click],This,[print])

Endwith

.Refresh

Endproc

ProcedureSetReport

LparametersoListenerRef

This.oListener=oListenerRef 

&

将对ReportListener对象的引用保存到表单的oListener属性中

ProcedureShow

LparametersnStyle

printshowbl=.t.

WithThis

IfVartype(.oListener)="

O"

.nPageHeight=.oListener.GetPageHeight()/10 

获得页面的像素高度(每英寸96DPI)

.nPageWidth=.oListener.GetPageWidth()/10 

获得页面的像素宽度

.shpPreview1.Height=Int(.nPageHeight) 

设置形状的高度

.shpPreview1.Width=Int(.nPageWidth) 

设置形状的宽度

.Caption="

标题中包含有报表的文件名称

.shpPreview1.left=(_screen.activeform.width-.shpPreview1.Width)/2&

根据当前窗口的大小,设置第一页的左边距

*-根据报表的页数添加预览页面

IF.oListener.OutputPageCount>

.VScrollSmallChange=200

FORi=2TO.oListener.OutputPageCount

shpbl="

shpPreview"

+ALLTRIM(STR(i))

.addobject("

shpbl"

"

myPreview"

.&

shpbl..visible=.t.

shpbl..left=.shpPreview1.left

shpbl..height=INT(.nPageHeight)

shpbl..width=INT(.npagewidth)

shpbl..top=10+(INT(.npageheight)+5)*(i-1)

IF.shpPreview1.left<

shpbl..left=0

ENDFOR

+ALLTRIM(STR(.oListener.OutputPageCount))

endtop=.&

shpbl..top

.shpPreview1.left=0

Endif

DoDefault(nStyle) 

执行默认的Show方法行为

ENDPROC

PROCEDUREscrolled 

LPARAMETERSnDirection,nShift,nXCoord,nYCoord

WITHthis

IFendtop+.shpPreview1.height-32765>

IF(nDirection=1ORnDirection=3)AND.&

shpbl..top+.shpPreview1.height>

32765

.shpPreview1.top=.shpPreview1.top-INT(endtop+.shpPreview1.height-32765)/157-1-10

FORj1=2TO.oListener.OutputPageCount

+ALLTRIM(STR(j1))

shpbl..top=.shpPreview1.top+(.shpPreview1.height+5)*(j1-1)

shpbl..width=.shpPreview1.width

shpbl..height=.shpPreview1.height

ENDIF

IF(nDirection=0ORnDirection=2)AND.shpPreview1.top<

10

.shpPreview1.top=.shpPreview1.top+INT((endtop+.shpPreview1.height-32765)/157)+1+10

IF.shpPreview1.top>

10

.shpPreview1.top=10

FORj2=2TO.oListener.OutputPageCount

+ALLTRIM(STR(j2))

shpbl..top=.shpPreview1.top+(.shpPreview1.height+5)*(j2-1)

FORj3=1TO.oListener.OutPutPageCount

+ALLTRIM(STR(j3))

IF.&

shpbl..top<

.viewporttop+INT(SYSMETRIC

(2)*0.5)AND.&

shpbl..top+.nPageHeight>

.viewporttop+INT(SYSMETRIC

(2)*0.5)

.nCurrentPage=j3

endfor

ENDWITH

ENDPROC 

ProcedurePaint

IfVartype(.oListener)="

.oListener.OutputPage(1,.shpPreview1,2)

1

FORi1=2TO.oListener.OutputPageCount

+ALLTRIM(STR(i1))

.oListener.OutputPage(i1,.&

shpbl,2)

.CmdRefresh()

PROCEDUREunload

*-工具栏显示(可选)

IFotoolbarbl=.f.andotoolbargb=.f.&

在工具栏未显示并且没有关闭的情况下(全局变量otoolbargb用于工具栏是否关闭)

showWINDOW常用&

隐藏“常用”工具栏

SETMARKOFBAR2OF显示vTO.t.&

显示“显示v”菜单中菜单编号为2的菜单项前的勾

otoolbarbl=.t.

********************

printshowbl=.f.&

返回预览窗口关闭(printshowbl为全局变量,可选)

endproc

ProcedureCMDRefresh

ProcedureQueryUnload

IfVartype(This.oListener)='

O'

.oListener.PreviewContainer=.Null. 

释放对报表预览程序对象的引用

.oListener.OnPreviewClose(.F.) 

关闭预览

.oListener=.Null.

*--指定页

ProcedureActionGotoPage

WithThisform

.oTools.Enabled=.F.

.oGoToPage.PageNo=.nCurrentPage

.oGoToPage.PageTotal 

=.oListener.OutputPageCount

.oGotoPage.Show()

If.oGoToPage.PageNo>

=1And.oGoToPage.PageNo<

=.oListener.OutputPageCount

.nCurrentPage=.oGoToPage.PageNo

+ALLTRIM(STR(.nCurrentPage))

shpbl..top>

upbl=.&

shpbl..top-32765+.shpPreview1.height

FORi=1TO.oListener.OutputPageCount

shpbl..top=.&

shpbl..top-upbl

downbl=-.&

shpbl..top+10

shpbl..top+downbl

.SetViewPort(.ViewPortLeft,.&

shpbl..top-5)

Thisform.CMDRefresh

Else

.oTools.Enabled=.T.

*--关闭按扭

ProcedurecmdCloseClick

IfVartype(.oListener)='

.oListener.PreviewContainer=.Null.

.oListener.OnPreviewClose(.F.)

.Release()

printshowbl=.f.

*--更改显示比例

ProcedureCboZooMInteractiveChange

LparametersvVal

.shpPreview1.Height=Int(.nPageHeight*Val(vVal)/100)

.shpPreview1.Width=Int(.nPageWidth*Val(vVal)/100)

.oListener.OutputPage(1,.shpPreview1,2)

.shpPreview1.left=(_screen.activeform.width-.shpPreview1.Width)/2

FORi2=2TO.oListener.OutputPageCount

+ALLTRIM(STR(i2))

shpbl..top=.shpPreview1.top+(.shpPreview1.height+5)*(i2-1)

.oListener.OutputPage(i2,.&

.viewporttop+INT(SYSMETRIC

(2)*0.6)AND.&

.viewporttop+INT(SYSMETRIC

(2)*0.6)

.nCurrentPage=i2

*--打印

ProcedurePrint

.oPrint.PageNo=.nCurrentPage

.oPrint.PageTotal 

.oPrint.Show()

If.oPrint.PrintOk=.T.

DoCase

*--打印所有的页

Case.oPrint.opgPrint.Value=1 

打印所有页

.oListener.CommandClauses.PrintRangeFrom=1

.oListener.CommandClauses.PrintRangeTo=.oListener.OutputPageCount

prt1=1

prt2=.oListener.OutputPageCount

*--打印当前页

Case.oPrint.opgPrint.Value=2

.oListener.CommandClauses.PrintRangeFrom= 

.nCurrentPage

.oListener.CommandClauses.PrintRangeTo 

=.nCurrentPage

prt1=.nCurrentPage

prt2=.nCurrentPage

*--打印页码范围

Case.oPrint.opgPrint.Value=3

.oListener.CommandClauses.PrintRangeFrom=.oPrint.spnPageNoFrom.Value

.oListener.CommandClauses.PrintRangeTo=.oPrint.spnPageNoTo.Value

prt1=.oPrint.spnPageNoFrom.Value

prt2=.oPrint.spnPageNoTo.Value

ENDCASE

IF.oPrint.prtfile.value=.f.

WAITWINDOW[请稍候,系统正在进行打印处理......]NOWAIT

SETPRINTERTONAME"

oCurPrinter"

REPORTFORM(RptName)RANGEprt1,prt2TOPRINTERnodialog

.oListener.CommandClauses.OutPutTo=1 

设置输出到打印机

ELSE

WAITWINDOW[系统正准备进行打印处理......]NOWAIT

*pbl=prt1

*recobl=prt2

.oListener.listenertype=1

DOtiffile

Enddefine

DefineClassCommandButtonAsCommandButton

Height=22

Width=23

Top=0

SpecialEffect=2

Caption=[]

DefineClassBaseReportListenerAsReportListener

ListenerType=1 

设置输出模式

OutputType=1&

输出类型

DynamicLineHeight=.F.

tifffilename="

DefineClassRe

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2