放入一個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 longwith fgd1 .clear
.formatstring = "^紙張編號|^紙張名稱|^紙張長度|^紙張寬度" for i = 0 to .cols - 1 .colwidth(i) = 1700 next i .allowuserresizing = flexresizecolumns .left = 0 .width = me.scalewidth end withgetpaperinfoend subprivate 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 subprivate sub form_resize() with fgd1 .left = 0 .width = me.scalewidth .height = me.scaleheight .top = 0 end withend sub