| 发表于: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函数 | | |
|