ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:24.35KB ,
资源ID:7283501      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7283501.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(打印和打印机设置函数.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

打印和打印机设置函数.docx

1、打印和打印机设置函数打印和打印机设置函数 打印函数用于在打印机上格式化输出数据。这组函数与各对象的Print()函数有所不同,程序在使用这组函数时,需要使用PrintOpen()函数打开一个打印作业,然后根据需要执行这组函数中的一个或多个函数,最后使用PrintClose()函数关闭打印作业。 打印机设置函数用于得到当前的打印机名称,设置应用程序使用的打印机,得到系统中包含的所有打印机,显示打印机设置对话框等。 1、Print() 功 能:以当前字体在打开的打印作业中打印一行或多行文本。 语 法:Print(printjobnumber,tab1,string,tab2)参 数:printjo

2、bnumber:用PrintOpen()函数打开的打印作业号;tab1:Integer类型,可选项,指定文本开始打印的位置,在开始打印字符串之前将打印光标移动到该位置,从打印区的左边界开始计算,以千分之一英寸为单位。如果打印光标已经位于指定位置、或打印光标已经超过了指定位置、或省略了该参数,那么,Print()函数从打印光标的当前位置开始打印string:string类型,指定要打印的字符串。如果字符串中包括回车换行字符(rn),那么该字符串将被分成多行输出,但是,除第一行之外,其它行忽略tab1参数指定的起始打印位置;tab2:Integer类型,可选项,指定字符串打印结束后打印光标移动到的

3、位置,从打印区的左边界开始计算,以千分之一英寸为单位。如果打印光标已经超过了指定位置,那么Print()函数忽略该参数,打印光标位于已打印字符串的尾部。如果省略了该参数,Print()函数把打印光标移动到下一行的起始位置;返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL,Print()函数返回NULL。用 法:在打印作业中,PowerBuilder使用打印光标来跟踪打印位置。打印光标保存了即将打印区域左上角的坐标。使用Print()函数打印文本后,PowerBuilder自动更新打印光标。 PowerBuilder使用行距来决定打印出的两行文本之间的

4、距离,行距与字符的高度成比例,缺省的行距是字符高度的1.2倍。使用PrintSetSpacing()函数可以改变行距。当Print()函数在下一行打印输出时,它把打印光标的x坐标设置为0、y坐标增加当前行距指示的数值。 由于每打印一行时Print()函数都自动调整打印光标的y坐标位置,因此,该函数会自动处理分页,因此,应用程序没有必要调用PrintPage()函数进行分页。 打印区由纸张的物理尺寸和边界空白决定,PrintSend()函数能够发送具体打印机的ESC控制序列,使用这个函数可以改变边界空白的大小。 另外,在打印开始之前,使用PrintDefineFont()和PrintSetFon

5、t()函数可以改变Print()使用的字体。示 例:This example opens a print job, prints the string Sybase Corporation in the default font, and then starts a new line: long Job / Define a blank page and assign the job an ID Job = PrintOpen( ) / Print the string and then start a new line Print(Job, Sybase Corporation) . Pri

6、ntClose(Job) This example opens a print job, prints the string Sybase Corporation in the default font, tabs 5 inches from the left edge of the print area but does not start a new line: long Job / Define a blank page and assign the job an ID Job = PrintOpen( ) / Print the string but do not start a ne

7、w line Print(Job, Sybase Corporation, 5000) . PrintClose(Job) The first Print statement below tabs half an inch from the left edge of the print area, prints the string Sybase Corporation, and then starts a new line. The second Print statement tabs one inch from the left edge of the print area, print

8、s the string Directors:, and then starts a new line: long Job / Define a blank page and assign the job an ID Job = PrintOpen( ) / Print the string and start a new line Print(Job, 500, Sybase Corporation) / Tab 1 inch from the left edge and print Print(Job, 1000, Directors:) . PrintClose(Job) The fir

9、st Print statement below tabs half an inch from the left edge of the print area prints the string Sybase Corporation, and then tabs 6 inches from the left edge of the print area but does not start a new line. The second Print statement prints the current date and then starts a new line: long Job / D

10、efine a blank page and assign the job an ID Job = PrintOpen( ) / Print string and tab 6 inches from the left edge Print(Job, 500, Sybase Corporation, 6000) / Print the current date on the same line Print(Job, String(Today() . PrintClose(Job) In a window that displays a database error message in a Mu

11、ltiLineEdit mle_message, the following script for a Print button prints a title with the date and time and the message: long li_prt li_prt = PrintOpen(Database Error) Print(li_prt, Database error - + String(Today(), mm/dd/yyyy) & + - + String(Now(), HH:MM:SS) Print(li_prt, ) Print(li_prt, mle_messag

12、e.text) PrintClose(li_prt) 2、PrintBitmap() 功 能:在打印区域的指定位置打印位图。 语 法:PrintBitmap ( printjobnumber, bitmap, x, y, width, height ) 参 数:printjobnumber:用PrintOpen()函数打开的打印作业号; bitmap:string类型,指定要打印的位图文件的文件名; x:integer类型,指定位图起始打印位置的x坐标,以千分之一英寸为单位; y:integer类型,指定位图起始打印位置的y坐标,以千分之一英寸为单位;width:integer类型,指定位图的

13、打印宽度,以千分之一英寸为单位。如果该参数的值指定为0,那么按图像的原始宽度打印;height:integer类型,指定位图的打印高度,以千分之一英寸为单位。如果该参数的值指定为0,那么按图像的原始高度打印。返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL,PrintBitmap()函数返回NULL。 用 法:执行PrintBitmap()函数后,打印光标的位置不变,依然停留在执行该函数前的位置上。 示 例:These statements define a new blank page and then print the bitmap in fi

14、le d:PBBITMAP1.BMP in its original size at location 50,100: long Job / Define a new blank page. Job = PrintOpen( ) / Print the bitmap in its original size. PrintBitmap(Job, d:PBBITMAP1.BMP, 50,100, 0,0) / Send the page to the printer and close Job. PrintClose(Job) 3、PrintCancel() 功 能:取消用PrintOpen()函

15、数启动的打印作业。 语 法:PrintCancel ( printjobnumber ) 参 数:printjobnumber:要取消的打印作业的作业号。返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果参数printjobnumber的值为NULL,PrintCancel()函数返回NULL。用 法:PrintCancel()函数取消指定的打印作业,删除相应的打印池文件,关闭打印作业,所以,应用程序执行了PrintCancel()函数之后,不需要再执行PrintClose()函数关闭打印作业了。 示 例:In this example, a script for a Pr

16、int button opens a print job and then opens a window with a cancel button. If the user clicks on the cancel button, its script sets a global variable that indicates that the user wants to cancel the job. After each printing command in the Print buttons script, the code checks the global variable and

17、 cancels the job if its value is TRUE. The definition of the global variable is: boolean gb_printcancel The script for the Print button is: long job, li gb_printcancel = FALSE job = PrintOpen(Test Page Breaks) IF job 1 THEN MessageBox(Error, Cant open a print job.) RETURN END IF Open(w_printcancel)

18、PrintBitmap(Job, d:PBbitmap1.bmp, 5, 10, 0, 0) IF gb_printcancel = TRUE THEN PrintCancel(job) RETURN END IF . / Additional printing commands, . / including checking gb_printcancel PrintClose(job) Close(w_printcancel) The script for the cancel button in the second window is: gb_printcancel = TRUE Clo

19、se(w_printcancel) 4、PrintClose() 功 能:关闭打印作业并把打印页面发送到打印机上。 语 法:PrintClose ( printjobnumber ) 参 数:printjobnumber:要关闭的打印作业的作业号。返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果参数printjobnumber的值为NULL,PrintClose()函数返回NULL。用 法:应用程序使用PrintOpen()函数启动打印作业后,必须使用PrintClose()在完成打印任务后关闭打印作业,或根据需要使用PrintCancel()函数取消打印作业。 示 例:

20、This example opens a print job, which creates a blank page, prints a bitmap on the page, then sends the current page to the printer or spooler and closes the job: ulong Job / Begin a new job and a new page. Job = PrintOpen( ) / Print the bitmap in its original size. PrintBitmap(Job, d:PBBITMAP1, 5,1

21、0, 0,0) / Send the page to the printer and close Job. PrintClose(Job) 5、PrintDataWindow()功 能:打印数据窗口控件的内容,用该函数可以在一个打印作业中打印多个数据窗口控件的内容,每个都从新的一页开始打印。 语 法:PrintDataWindow ( printjobnumber, dwcontrol ) 参 数:printjobnumber:用PrintOpen()函数打开的打印作业号; dwcontrol:要打印其内容的数据窗口控件名或子数据窗口控件名。返回值:Integer。函数执行成功时返回1,发生错

22、误时返回-1。如果参数printjobnumber的值为NULL,PrintDataWindow()函数返回NULL。用 法:应用程序通过多次执行PrintDataWindow()函数可以在一个打印作业中一次打印多个数据窗口的 内容,并且每个数据窗口都从新的一页开始打印。当数据窗口的表现风格为RichTextEdit时,数据窗口中的每一行都在新的一页上开始打印。 需要注意的是,PrintDataWindow()函数在打印数据窗口时使用数据窗口本身定义的字体以及风格,使用PrintDefineFont()和PrintSetFont()函数为当前作业定义的字体不起作用。 示 例:These sta

23、tements send the contents of three DataWindow controls to the current printer in a single print job: long job job = PrintOpen( ) / Each DataWindow starts printing on a new page. PrintDataWindow(job, dw_EmpHeader) PrintDataWindow(job, dw_EmpDetail) PrintDataWindow(job, dw_EmpDptSum) PrintClose(job) 6

24、、PrintDefineFont() 功 能:定义打印作业使用的字体,对每个打印作业PowerBuilder支持八种字体。语 法:PrintDefineFont(printjobnumber,fontnumber,facename,height,weight,fontpitch,fontfamily, italic,underline) 参 数:printjobnumber:用PrintOpen()函数打开的打印作业号;fontnumber:指定赋给当前定义字体的编号,有效值在1到8之间 facename:string类型,指定字体名称,该字体应该是你的打印机支持的字体,比如“宋体”;heig

25、ht:Integer类型,使用正值指定字体的高度,以千分之一英寸为单位;使用负值指定字体点数,比如,-18代表18点。一般来说,使用点数更精确些; weight:指定字体的磅数,正常字体为400磅,粗体为700磅; fontpitch:FontPitch枚举类型,指定字体标准。有效取值为: Default! - 缺省值; Fixed! - 固定形式; Variable! - 可变形式; fontfamily:FontFamily枚举类型,指定字体系列。有效取值为: AnyFont!、Decorative!、Modern!、Roman!、Script!、Swiss! italic:boolean

26、类型,指定是否使用斜体样式。有效取值为: TRUE - 使用斜体样式; FALSE - 不使用斜体样式; 缺省值为FALSE; underline:boolean类型,指定是否加下划线。有效取值为: TRUE - 加下划线; FALSE - 不加下划线; 缺省值为FALSE。返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL,PrintDefineFont()函数返回NULL。用 法:在一个打印作业中,应用程序能够最多同时定义8种字体。当应用程序需要使用更多的字体时,可以在使用了某个字体号输出内容后使用PrintDefineFont()函数将该字体号对

27、应的字体更换为其它字体。 示 例:These statements define a new blank page, and then define print font 1 for Job as Courier 10Cpi, 18 point, normal weight, default pitch, Decorative font, with no italic or underline: long Job Job = PrintOpen() PrintDefineFont(Job, 1, Courier 10Cpi, -18, 400, Default!, Decorative!, F

28、ALSE, FALSE) 7、PrintLine() 功 能:在当前打印页上绘出指定厚度的一条线。 语 法:PrintLine ( printjobnumber, x1, y1, x2, y2, thickness ) 参 数:printjobnumber:用PrintOpen()函数打开的打印作业号; x1:integer类型,指定直线起点的x坐标,以千分之一英寸为单位; y1:integer类型,指定直线起点的y坐标,以千分之一英寸为单位; x2:integer类型,指定直线终点的x坐标,以千分之一英寸为单位; y2:integer类型,指定直线终点的y坐标,以千分之一英寸为单位; thi

29、ckness:integer类型,指定直线的厚度,以千分之一英寸为单位。返回值:Integer。函数执行成功时返回1,发生错误时返回-1。如果任何参数的值为NULL,PrintLine()函数返回NULL。 用 法:应用程序执行了PrintLine()函数后,该函数并不改变打印光标的位置。 示 例:These statements start a new page in a print job and then print a line starting at 0,5 and ending at 7500,5 with a thickness of 10/1000 of an inch: lo

30、ng Job Job = PrintOpen( ) . / various print commands / Start a new page. PrintPage(Job) / Print a line at the top of the page PrintLine(Job,0,5,7500,5,10) . / Other printing PrintClose(Job) 8、PrintOpen() 功 能:启动打印作业并返回作业号。 语 法:PrintOpen ( jobname ) 参 数:jobname:string类型,可选项,指定要打开打印作业的名称,该名称将显示在打印管理器窗口

31、中。 返回值:Long。函数执行成功时返回打印作业号,发生错误时返回-1。如果任何参数的值为NULL, PrintOpen()函数返回NULL。用 法:应用程序执行PrintOpen()函数后,启动新的打印作业并走纸到下一页,同时将打印机缺省字体设置为该打印作业的字体。打印光标的位置位于打印区的左上角。其它同组的打印函数使用PrintOpen()函数返回的作业号来标识作业。 需要注意的是,使用PrintOpen()函数打开打印作业、使用同组的其它函数完成打印任务后,必须使用PrintClose()关闭打印作业,或根据需要使用PrintCancel()函数取消打印作业。 示 例:This example opens a job but does not give it a name: ulong li_job li_job = PrintOpen() This example opens a job and gives it a name: ulong li_job

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1