欢迎光临
我们一直在努力

VB中获取指定打印机的各种纸张类型及大小-.NET教程,VB.Net语言

建站超值云服务器,限时71元/月

 

放入一个msflexgrid,名称为fgd1,列数为4
option explicit
private const dc_maxextent = 5
private const dc_minextent = 4
private const dc_papernames = 16
private const dc_papers = 2
private const dc_papersize = 3
private declare function devicecapabilities lib “winspool.drv” alias “devicecapabilitiesa” (byval lpdevicename as string, byval lpport as string, byval iindex as long, lpoutput as any, lpdevmode as any) as long
private type points
        x  as long
        y  as long
end type
private sub form_load()
dim i as long
with fgd1
    .clear
   
    .formatstring = “^纸张编号|^纸张名称|^纸张长度|^纸张宽度”
    for i = 0 to .cols – 1
        .colwidth(i) = 1700
    next i
    .allowuserresizing = flexresizecolumns
    .left = 0
    .width = me.scalewidth
end with
getpaperinfo
end sub
private sub getpaperinfo()
dim i as long, ret as long
dim length as integer, width as integer
dim paperno() as integer, papername() as string, papersize() as points
支持最大打印纸:
ret = devicecapabilities(打印机名称, “lpt1”, dc_maxextent, byval 0&, byval 0&)
length = ret \ 65536
width = ret – length * 65536
lblmaxlength.caption = length
lblmaxwidth.caption = width
支持最小打印纸:
ret = devicecapabilities(打印机名称, “lpt1”, dc_minextent, byval 0&, byval 0&)
length = ret \ 65536
width = ret – length * 65536
支持纸张种类数
ret = devicecapabilities(打印机名称, “lpt1”, dc_papers, byval 0&, byval 0&)
纸张编号
redim paperno(1 to ret) as integer
call devicecapabilities(打印机名称, “lpt1”, dc_papers, paperno(1), byval 0&)
纸张名称
dim arrpagename() as byte
dim allnames as string
dim lstart as long, lend as long
redim papername(1 to ret) as string
redim arrpagename(1 to ret * 64) as byte
call devicecapabilities(打印机名称, “lpt1”, dc_papernames, arrpagename(1), byval 0&)
allnames = strconv(arrpagename, vbunicode)
loop through the string and search for the names of the papers
i = 1
do
    lend = instr(lstart + 1, allnames, chr$(0), vbbinarycompare)
    if (lend > 0) and (lend – lstart – 1 > 0) then
        papername(i) = mid$(allnames, lstart + 1, lend – lstart – 1)
        i = i + 1
    end if
    lstart = lend
loop until lend = 0
纸张尺寸
redim papersize(1 to ret) as points
call devicecapabilities(form2.combo1.text, “lpt1”, dc_papersize, papersize(1), byval 0&)
显示在表格中
for i = 1 to ret
    fgd1.additem paperno(i) & vbtab & papername(i) & vbtab & papersize(i).y & vbtab & papersize(i).x
next i
移除第一个空行
fgd1.row = 1
fgd1.removeitem 1
end sub
private sub form_resize()
with fgd1
    .left = 0
    .width = me.scalewidth
    .height = me.scaleheight
    .top = 0
end with
end sub

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » VB中获取指定打印机的各种纸张类型及大小-.NET教程,VB.Net语言
分享到: 更多 (0)

相关推荐

  • 暂无文章