PrintingDevice.DeviceCapabilities 方法 |
命名空间: XSharp.VO.SDK
1SELF:oPrint //假定是一个Printer对象 2 3METHOD FillPaperSizesListBox() CLASS; MyPrintReportWindow 4 LOCAL aDisplayValues, aReturnValues, aListBoxValues := {} AS ARRAY 5 LOCAL i, wALen AS DWORD 6 7 aDisplayValues := SELF:oPrint:PrintingDevice:DeviceCapabilities(DC_PAPERNAMES) 8 aReturnValues := SELF:oPrint:PrintingDevice:DeviceCapabilities(DC_PAPERS) 9 wALen := ALen(aDisplayValues) 10 11 FOR i := 1 UPTO wALen 12 aAdd(aListBoxValues, {aDisplayValues[i], aReturnValues[i]}) 13 NEXT 14 15 RETURN aListBoxValues
1LOCAL uValue AS USUAL 2LOCAL oP, oPD AS OBJECT 3// 使用默认设备创建打印机对象并 4// 获取对PrintingDevice对象的引用 5oP := Printer{} 6oPD := oP:PrintingDevice 7// 列出可用纸张大小的名称 8uValue := oPD:DeviceCapabilities(DC_PAPERNAMES) 9QOut("Show "+"DC_PAPERNAMES") 10ShowValue(uValue) 11InKey(0) 12// 列出可用纸张的名称 13uValue := oPD:DeviceCapabilities(DC_PAPERNAMES) 14QOut("Show "+"DC_PAPERNAMES") 15ShowValue(uValue) 16InKey(0) 17// 销毁打印机对象(回收GDI资源) 18oP:Destroy() 19 20FUNCTION ShowValue(uValue) 21 IF IsArray(uValue) 22 AEval(uValue, {|u| ShowValue(u)}); 23 // 递归,直到找到单个元素 24 ELSEIF IsNumeric(uValue) .AND.; 25 uValue = CAPABILITY_NOT_AVAIALBLE 26 QOut ("Device capability not available from driver") 27 ELSE 28 QOut(uValue) 29 ENDIF