定义下面自定义函数,然后在程序中调用。
environment env
integer rtn
rtn = GetEnvironment(env)
IF rtn <> 1 THEN return false
if env.OSType=Windows! then //win98!
return SetPaperSize(ai_Width,ai_Height,ai_Orient)=1
else
if env.OSType=WindowsNT! then
string printerName
string paperName
boolean rt
papername=string(ai_width)+"*" +string(ai_height)
printerName = space(255)
rt = GetDefaultPrinter(ref printerName, 255)
if rt then
//messagebox("",trim(printerName))
printername= trim(printerName)
else
return false
end if
DeleteCustomPaper(ref printerName, ref paperName) //先删除纸张
rt = AddCustomPaper(ref printerName, ref PaperName, ai_width, ai_height, 0, 0, 0, 0)
if rt=false then return rt
rt = SetDefaultpaper(ref printerName, ref paperName, ai_orient)
return rt
end if
end if