您的位置:程序门 -> vb -> 基础类



如何将通过commondialog对话框里设置的纸张大小赋值给print对象。


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何将通过commondialog对话框里设置的纸张大小赋值给print对象。
发表于:2007-03-14 09:05:20 楼主
如何将通过commondialog对话框里设置的纸张大小赋值给print对象。
发表于:2007-03-14 21:23:531楼 得分:0
papersize   属性

返回或设置一个值,该值指出当前打印机的纸张大小。在设计时是不可用。

语法

object.papersize   [=   value]

papersize   属性的语法包含下面部分:

部分 描述
object 对象表达式,其值是“应用于”列表中的一个对象。
value 一个用来指定纸张大小的值或常数,“设置值”中有详细描述。
设置值

value   的设置值是:

常数 值 描述
vbprpsletter 1 信笺,   8   1/2   x   11   英寸。  
vbprpslettersmall 2 +a611   小型信笺,   8   1/2   x   11   英寸。
vbprpstabloid 3 小型报,   11   x   17   英寸。
vbprpsledger 4 分类帐,   17   x   11   英寸。
vbprpslegal 5 法律文件,   8   1/2   x   14   英寸。
vbprpsstatement 6 声明书,5   1/2   x   8   1/2   英寸。
vbprpsEXECutive 7 行政文件,7   1/2   x   10   1/2   英寸。
vbprpsa3 8 a3,   297   x   420   毫米  
vbprpsa4 9 a4,   210   x   297   毫米  
vbprpsa4small 10 a4小号,   210   x   297   毫米
vbprpsa5 11 a5,   148   x   210   毫米  
vbprpsb4 12 b4,   250   x   354   毫米  
vbprpsb5 13 b5,   182   x   257   毫米  
vbprpsfolio 14 对开本,   8   1/2   x   13   英寸。
vbprpsquarto 15 四开本,   215   x   275   毫米。
vbprps10x14 16 10   x   14   英寸。
vbprps11x17 17 11   x   17   英寸。  
vbprpsnote 18 便条,8   1/2   x   11   英寸。
vbprpsenv9 19 #9   信封,   3   7/8   x   8   7/8   英寸。
vbprpsenv10 20 #10   信封,   4   1/8   x   9   1/2   英寸。
vbprpsenv11 21 #11   信封,   4   1/2   x   10   3/8   英寸。  
vbprpsenv12 22 #12   信封,   4   1/2   x   11   英寸。
vbprpsenv14 23 #14   信封,   5   x   11   1/2   英寸。
vbprpscsheet 24 c   尺寸工作单
vbprpsdsheet 25 d   尺寸工作单
vbprpsesheet 26 e   尺寸工作单
vbprpsenvdl 27 dl   型信封,   110   x   220   毫米
vbprpsenvc3 29 c3   型信封,   324   x   458   毫米
vbprpsenvc4 30 c4   型信封,   229   x   324   毫米
vbprpsenvc5 28 c5   型信封,   162   x   229   毫米
vbprpsenvc6 31 c6   型信封,   114   x   162   毫米
vbprpsenvc65 32 c65   型信封,114   x   229   毫米
vbprpsenvb4 33 b4   型信封,   250   x   353   毫米
vbprpsenvb5 34 b5   型信封,176   x   250   毫米
vbprpsenvb6 35 b6   型信封,   176   x   125   毫米
vbprpsenvitaly 36 信封,   110   x   230   毫米
vbprpsenvmonarch 37 信封大王,   3   7/8   x   7   1/2   英寸。
vbprpsenvpersonal 38 信封,   3   5/8   x   6   1/2   英寸。
vbprpsfanfoldus 39 u.s.   标准复写簿,   14   7/8   x   11   英寸。  
vbprpsfanfoldstdgerman 40 德国标准复写簿,   8   1/2   x   12   英寸。
vbprpsfanfoldlglgerman 41 德国法律复写簿,   8   1/2   x   13   英寸。  
vbprpsuser 256 用户定义
说明

这些常数在   visual   basic   (vb)   中的对象浏览器中的对象库中列出。
打印机   height   和   width   属性的设置自动地将   papersize   设置为   vbprpsuser。

注意       printer   对象此属性的效果依赖于打印机厂家提供的驱动程序。某些属性设置值可能不起作用,或者一些不同的属性设置值可能有相同的效果。接受范围之外的设置值可能产生也可能不产生错误。详细信息,请参阅厂家具体驱动程序的文档。
发表于:2007-03-14 21:24:462楼 得分:0
更多资料去此处查:
http://www.egooglet.com

论坛
http://bbs.j2soft.cn
发表于:2007-03-15 08:44:153楼 得分:0
你说的页面大小的值我怎么能从commondialog对话框里得到啊?
发表于:2007-04-29 14:18:124楼 得分:0
关注中...
发表于:2007-04-29 16:06:355楼 得分:0
option   explicit

public   const   physicalwidth   =   110
public   const   physicalheight   =   111
public   const   physicaloffsetx   =   112
public   const   physicaloffsety   =   113

public   declare   function   getdevicecaps   lib   "gdi32 "   (byval   hdc   as   long,   byval   nindex   as   long)   as   long
public   physwidth   as   single,   physheight   as   single                 '纸张宽,高度
public   printwidth   as   single,   printheight   as   single       '可列印宽,高度
public   topmargin   as   single,   bottommargin   as   single           '上,下边界
public   leftmargin   as   single,   rightmargin   as   single       '左,右边界

public   ncopy   as   integer   '列印份数
public   nrows   as   integer   '排列行数
public   ncols   as   integer   '排列列数
public   nrowspace   as   long   '行距
public   ncolspace   as   long   '列距
public   nleftspace   as   long   '左边距
public   ntopspace   as   long     '上边距
public   strprint   as   string   '需列印的字符


public   xobj   as   object


public   sub   showprinter()
        'getdevicecaps   回传值的单位是   pixels
        printer.scalemode   =   1   'vbpixels   '像素
        '计算部份
        physwidth   =   getdevicecaps(printer.hdc,   physicalwidth)           '纸张实际宽度
        physheight   =   getdevicecaps(printer.hdc,   physicalheight)       '纸张实际高度
        printwidth   =   printer.scalewidth                                                       '可列印范围宽度
        printheight   =   printer.scaleheight                                                   '可列印范围高度
        leftmargin   =   getdevicecaps(printer.hdc,   physicaloffsetx)     '左边界
        rightmargin   =   physwidth   -   (leftmargin   +   printwidth)               '右边界
        topmargin   =   getdevicecaps(printer.hdc,   physicaloffsety)       '上边界
        bottommargin   =   physheight   -   (topmargin   +   printheight)           '下边界

end   sub
把以上放入一模块中

设置好打印属性后再调用showprinter函数


快速检索

最新资讯
热门点击